SBCL返回handle-win32-exception

时间:2017-09-19 06:48:04

标签: c++ common-lisp sbcl cffi

我想用cffi从SBCL调用c ++函数。我试着调用以下非常简单的函数。

#include <stdio.h>

void print1() {
printf("Hello World!");
}

我用gcc制作了.so文件。

gcc -Wall -fpic -shared "c:/Users/***/Documents/tmp/test.c" -o "c:/Users/***/f_libraries/libtest.so" -m64`

文件创建如下: C:/Users/***/f_libraries/libtest.so: PE32+ executable (DLL) (console) x86-64, for MS Windows

我可以从sbcl读取这个文件,但是当我打电话给&#34; print1&#34;功能,我收到以下错误信息。

当我第一次打电话时,我得到了

* (cffi:foreign-funcall "print1" :void)

debugger invoked on a SB-SYS:MEMORY-FAULT-ERROR in thread
#<THREAD "main thread" RUNNING {1002DBA553}>:
  Unhandled memory fault at #x28.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

debugger invoked on a SB-SYS:MEMORY-FAULT-ERROR in thread
#<THREAD "main thread" RUNNING {1002DBA553}>:
  Unhandled memory fault at #xFFFFFFFFFFFFFFFF.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-DEBUG::DEBUG-LOOP-FUN)
0] backtrace

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1002DBA553}>
0: (SB-DEBUG::DEBUG-LOOP-FUN)
1: (INTERNAL-DEBUG)
2: (SB-DEBUG::%INVOKE-DEBUGGER #<SB-SYS:MEMORY-FAULT-ERROR {1006390E03}>)
3: ((LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX))
4: (SB-IMPL::CALL-WITH-SANE-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {10063910CB}>)
5: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<CLOSURE (FLET #:THUNK :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {2281EB}>)
6: (SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX #<FUNCTION SB-DEBUG::%INVOKE-DEBUGGER> #<SB-SYS:MEMORY-FAULT-ERROR {1006390E03}>)
7: (INVOKE-DEBUGGER #<SB-SYS:MEMORY-FAULT-ERROR {1006390E03}>)
8: (ERROR SB-SYS:MEMORY-FAULT-ERROR :ADDRESS 18446744073709551615)
9: (SB-KERNEL:HANDLE-WIN32-EXCEPTION #.(SB-SYS:INT-SAP #X002284F0) #.(SB-SYS:INT-SAP #X00229220))
10: ("foreign function: #x4338BC")

0] 0
;
; compilation unit aborted
;   caught 1 fatal ERROR condition

第二次之后,

* (cffi:foreign-funcall "print1" :void)

debugger invoked on a SB-SYS:MEMORY-FAULT-ERROR in thread
#<THREAD "main thread" RUNNING {1002DBA553}>:
  Unhandled memory fault at #xFFFFFFFFFFFFFFFF.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-KERNEL:HANDLE-WIN32-EXCEPTION #.(SB-SYS:INT-SAP #X0022B3A0) #.(SB-SYS:INT-SAP #X0022C0D0))
0] backtrace

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1002DBA553}>
0: (SB-KERNEL:HANDLE-WIN32-EXCEPTION #.(SB-SYS:INT-SAP #X0022B3A0) #.(SB-SYS:INT-SAP #X0022C0D0))
1: ("foreign function: #x4338BC")

0] 0
;
; compilation unit aborted
;   caught 1 fatal ERROR condition

我的电脑是Windows 7(64位)。 有没有人知道这个问题?

0 个答案:

没有答案