2
我是一个lisp noob尝试使用sbcl v1.0.50学习lisp。Lisp IO问题
我正在写一个简单的记录器和运行到一个内存故障,我不明白,但似乎与我如何编译我的 脚本有关。我已经熬它归结为以下几点:
=== logger.lisp ===
(defparameter *log-stream* (open "/tmp/global-log"
:direction :output
:if-does-not-exist :create
:if-exists :append))
=== main.lisp ===
(load "logger.lisp")
(defun main()
(format *log-stream* "Hello world~%"))
== compile.lisp ==
#! /usr/bin/sbcl --script
(load "main.lisp")
(save-lisp-and-die "program" :toplevel #'main :executable t)
当我编译并运行该程序崩溃:
> ./compile.lisp
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into foo:
writing 6352 bytes from the read-only space at 0x20000000
writing 4064 bytes from the static space at 0x20100000
writing 43057152 bytes from the dynamic space at 0x1000000000
> ./program
CORRUPTION WARNING in SBCL pid 21860(tid 140737353914112):
Memory fault at f6977000 (pc=0x1000036365, sp=0x7ffff6b7f8d0)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
unhandled SB-SYS:MEMORY-FAULT-ERROR in thread #<SB-THREAD:THREAD
"initial thread" RUNNING
{10029118D1}>:
Unhandled memory fault at #x7FFFF6977000.
0: (SB-DEBUG::MAP-BACKTRACE
#<CLOSURE (LAMBDA #) {100291A3C9}>
:START
0
:COUNT
128)
1: (BACKTRACE 128 #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDERR* {100001CEB1}>)
2: (SB-DEBUG::DEBUGGER-DISABLED-HOOK
#<SB-SYS:MEMORY-FAULT-ERROR {10029180E1}>
#<unavailable argument>)
3: (SB-DEBUG::RUN-HOOK
*INVOKE-DEBUGGER-HOOK*
#<SB-SYS:MEMORY-FAULT-ERROR {10029180E1}>)
4: (INVOKE-DEBUGGER #<SB-SYS:MEMORY-FAULT-ERROR {10029180E1}>)
5: (ERROR SB-SYS:MEMORY-FAULT-ERROR :ADDRESS 140737330507776)
6: (SB-SYS:MEMORY-FAULT-ERROR)
7: ("foreign function: #x4174A0")
8: ("foreign function: #x417580")
9: (SB-IMPL::OUTPUT-BYTES/UTF-8
#<SB-SYS:FD-STREAM for "file /tmp/global-log" {10001B8A81}>
"AAAA"
NIL
0
4)
10: (SB-IMPL::FD-SOUT
#<SB-SYS:FD-STREAM for "file /tmp/global-log" {10001B8A81}>
"AAAA"
0
4)
11: (SB-IMPL::%WRITE-STRING
"AAAA"
#<SB-SYS:FD-STREAM for "file /tmp/global-log" {10001B8A81}>
0
NIL)
12: ((LAMBDA (STREAM &OPTIONAL &REST SB-FORMAT::ARGS))
#<SB-SYS:FD-STREAM for "file /tmp/global-log" {10001B8A81}>)
13: (FORMAT
#<SB-SYS:FD-STREAM for "file /tmp/global-log" {10001B8A81}>
#<FUNCTION (LAMBDA #) {100002F6C9}>)
14: ((FLET #:WITHOUT-INTERRUPTS-BODY-[RESTART-LISP]30))
15: ((LABELS SB-IMPL::RESTART-LISP))
unhandled condition in --disable-debugger mode, quitting
我试了一会儿才明白发生了什么,但嗯。帮助 将不胜感激!
Anders
啊,当然!我必须习惯这种倾倒图像 以获得可执行文件。谢谢。 – aklt