lispgames / cl-sdl2

Common Lisp bindings for SDL2 using C2FFI.
MIT License
309 stars 82 forks source link

(sdl2-examples:basic-test) crashes with 'NSInternalInconsistencyException' #91

Closed elevatorsimulator closed 7 years ago

elevatorsimulator commented 7 years ago

My system:

When I run

(ql:quickload :sdl2)
(asdf:load-system :sdl2/examples)
(sdl2-examples:basic-test)

I get this nasty error:

Using SDL Library Version: 2.0.4
Setting up window/gl.
Opening game controllers.
Beginning main loop.
2017-06-09 20:56:28.827 sbcl[1504:99014] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fffb8bc957b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffcde0d1da objc_exception_throw + 48
    2   AppKit                              0x00007fffb6db5e82 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 4480
    3   SDL2                                0x0000000000452a5a SDL2 + 244314
    4   SDL2                                0x000000000043e39d SDL2 + 160669
    5   ???                                 0x0000000022b8f0ee 0x0 + 582545646
    6   ???                                 0x0000000022bd9b89 0x0 + 582851465
    7   ???                                 0x0000000022bd9606 0x0 + 582850054
    8   ???                                 0x0000000022bb07c6 0x0 + 582682566
    9   ???                                 0x0000000022bb11a9 0x0 + 582685097
    10  ???                                 0x00000000229c2640 0x0 + 580658752
)
libc++abi.dylib: terminating with uncaught exception of type NSException
fatal error encountered in SBCL pid 1504(tid 0xb0000000):
SIGABRT received.
rmhsilva commented 7 years ago

Same. Here's a bit more backtrace from mine:

ldb> backtrace
Backtrace:
   0: Foreign function __pthread_kill, pc = 0x7fffa0722d42, fp = 0x39fda00
   1: Foreign function abort, pc = 0x7fffa0688420, fp = 0x39fda30
   2: Foreign function __cxa_bad_cast, pc = 0x7fff9f1e284a, fp = 0x39fdb50
   3: Foreign function _ZL26default_unexpected_handlerv, pc = 0x7fff9f207c4f, fp = 0x39fdf90
   4: Foreign function _ZL15_objc_terminatev, pc = 0x7fff9fd1533e, fp = 0x39fdfb0
   5: Foreign function _ZSt11__terminatePFvvE, pc = 0x7fff9f204d69, fp = 0x39fdfd0
   6: Foreign function _ZN10__cxxabiv1L22exception_cleanup_funcE19_Unwind_Reason_CodeP17_Unwind_Exception, pc = 0x7fff9f2047de, fp = 0x39fe000
   7: Foreign function objc_exception_throw, pc = 0x7fff9fd13303, fp = 0x39fefe0
   8: Foreign function -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:], pc = 0x7fff88b3be82, fp = 0x39ff290
   9: Foreign function Cocoa_PumpEvents, pc = 0x590c9b, fp = 0x39ff2f0
  10: Foreign function SDL_PumpEvents_REAL, pc = 0x530568, fp = 0x39ff300
  11: Foreign function SDL_WaitEventTimeout_REAL, pc = 0x5305d0, fp = 0x39ff330
  12: SDL2::NEXT-EVENT, pc = 0x22bb778c, fp = 0x39ff3a0
  13: (LAMBDA () :IN SDL2-EXAMPLES::BASIC-TEST), (LAMBDA () :IN SDL2-EXAMPLES::BASIC-TEST), (LAMBDA () :IN SDL2-EXAMPLES::BASIC-TEST), pc = 0x22be3e39, fp = 0x39ff4b0
  14: (LAMBDA () :IN SDL2-EXAMPLES::BASIC-TEST), (LAMBDA () :IN SDL2-EXAMPLES::BASIC-TEST), (LAMBDA () :IN SDL2-EXAMPLES::BASIC-TEST), pc = 0x22be38b7, fp = 0x39ff5c0
z3t0 commented 7 years ago

Also having the same issue.

z3t0 commented 7 years ago

Try using Clozure CL, worked for me at least. Also install SDL2 directly as a framework from here instead of brew.

rmhsilva commented 7 years ago

@z3t0 oops, forgot to follow this up - CCL with SDL2 framework fixed things for me too. Thanks.

tavurth commented 7 years ago

I also had this issue. OSX 10.12.6, SBCL 1.3.21.

While CCL works, being able to use SBCL is a big deal for me, as I like the warnings.

The code can be run under SBCL by specifying that the current thread should be the main working thread from which calls to clibs are made:

(ql:quickload :sdl2/examples)

#-sbcl (sdl2-examples:basic-test)
#+sbcl (sdl2:make-this-thread-main #'sdl2-examples:basic-test)

Hopefully that'll help someone)