Closed MartinDelille closed 4 years ago
Thanks for the report!
I assume you use Mac, and used Homebrew to install D/Allegro/enet.
In this case, your report matches the Mac black-screen issue that we discussed on IRC in January 2019 (link to Lemmings Forums thread. We had not solved this, and since I don't have a Mac, I didn't dive deeper into this issue. But apparently it's become normal on Mac that Lix either crashes or presents the black screen -- we should investigate.
3 ideas on how to proceed:
I'll prepare a small test program to display simple graphics with D and Allegro 5, i.e., no networking, no music, no extra files that the game needs, ... I'll come back to you with that in 1-3 days. We'll then see if at least such a very simple D/Allegro program works for you.
Besides the test program, you can investigate the crash of Lix with a debugger. I'm familiar with gdb on Linux, unsure what's popular on Mac. Instructions for gdb: Start Lix with debugger attached via $ gdb lix
, at gdb's prompt type run -w
to run Lix with Lix's switch -w
that forces windowing mode, wait for the crash, then type bt
to see the stacktrace of the crashed Lix. To quit, q
, then y
. But you mentioned that Lix consumes lots of system resources; it's possible then that the stacktrace won't help much because Lix is merely killed at a random time by the operating system that wants the resources back.
If other methods have failed: You could install debugging libraries for Allegro 5 (unsure if that's possible via Homebrew -- compiling Allegro 5 yourself is more work than compiling Lix). Then the small test program produces an allegro.log
with more details. Lix would then also produce an allgero.log
, but a very large, near-unusuable one because Lix does so much with Allegro 5.
Which particular macOS do you use? macOS 10.14.1 had a problem with OpenGL, a simple Allegro 5 example written in C already produced a black screen there: https://github.com/liballeg/allegro5/issues/960
Thanks for answering!
Which particular macOS do you use? macOS 10.14.1
macOS 10.14.3
I'll try to debug it with gbd
when I'll have time to do so!
I've created a minimal example with D and Allegro 5.2. Clone or download it, enter its directory, and run it with dub
. (I assume you have D and Allegro 5.2 installed already.)
The example program will create a window. Does this window show red, green, and blue for 2 seconds each? Or is the window entirely black for 6 seconds instead?
Sorry for taking a week.
I tried your project with success! I indeed see the three color red/green/blue for about 6 seconds.
Thanks for the quick feedback! I'm surprised the example works perfectly for you, very good to know.
All right, I'll have to reduce this issue by digging into Lix's graphics fundamentals, or by extending the minimal example with more things from Lix. I'll get back to you once I have a new tests.
Do you have lldb
installed? This is likely when you use Xcode on Mac. Then you don't have to install gdb
. With lldb
, you can debug the crash too:
bin/lix
.$ lldb bin/lix
(lldb) run
(lldb) bt all
This will print the backtrace of all threads of Lix into the shell, please show me that backtrace.
When you're done, (lldb) quit
to quit.
(It's possible that your crash and black screen are related. Maybe Lix enters infinite recursion? This would show in the backtrace. We had infinite recursion last year and I've fixed a bug in the Allegro 5 D bindings, it shouldn't happen anymore, but one never knows.)
I tried again and was able to see this screen followed by a crash right after validating my name:
I upgraded my mac to 10.14.4 since then which may explains the change in behavior.
When I try to debug it with lldb
, I have the following output:
lldb bin/lix
(lldb) target create "bin/lix"
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Current executable set to 'bin/lix' (x86_64).
(lldb) run
Process 54883 launched: '/Users/martin/dev/clone/LixD/bin/lix' (x86_64)
2019-04-23 13:50:30.525648+0200 lix[54883:1280345] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=54883
2019-04-23 13:50:30.525764+0200 lix[54883:1280345] SecTaskCopyDebugDescription: lix[54883]/0#-1 LF=0
Process 54883 stopped
* thread #5, stop reason = EXC_BAD_ACCESS (code=1, address=0xf)
frame #0: 0x000000000000000f
error: memory read failed for 0x0
Target 0: (lix) stopped.
(lldb) bt all
error: need to add support for DW_TAG_base_type 'immutable(char)' encoded with DW_ATE = 0x10, bit_size = 8
error: need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x10, bit_size = 8
error: need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x10, bit_size = 8
thread #1, queue = 'com.apple.main-thread'
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff3058f13e CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff3058e6ac CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff3058de0e CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00007fff2f87a9db HIToolbox`RunCurrentEventLoopInMode + 292
frame #6: 0x00007fff2f87a715 HIToolbox`ReceiveNextEventCommon + 603
frame #7: 0x00007fff2f87a4a6 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64
frame #8: 0x00007fff2dc14ffb AppKit`_DPSNextEvent + 965
frame #9: 0x00007fff2dc13d93 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
frame #10: 0x00007fff2dc0deb0 AppKit`-[NSApplication run] + 699
frame #11: 0x0000000101253ad7 liballegro.5.2.dylib`_al_osx_run_main + 1312
frame #12: 0x00000001002a793c lix`_D8allegro56system14al_run_allegroFMDFZiZi(user_main=int delegate() @ 0x00007ffeefbff400) at system.d:36
frame #13: 0x000000010007515b lix`_Dmain(args=string[] @ 0x00007ffeefbff460) at main.d:35
frame #14: 0x000000010042a580 lix`_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 112
frame #15: 0x000000010042a373 lix`_d_run_main + 547
frame #16: 0x00000001000760a5 lix`main(argc=1, argv=0x00007ffeefbff5e8) at __entrypoint.d:8
frame #17: 0x00007fff5ca063d5 libdyld.dylib`start + 1
frame #18: 0x00007fff5ca063d5 libdyld.dylib`start + 1
thread #3
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
* thread #5, stop reason = EXC_BAD_ACCESS (code=1, address=0xf)
* frame #0: 0x000000000000000f
frame #1: 0x000000010010e29a lix`_D4file6option7allopts14displayTryModeFNbNdZSQBrQBpQBl14DisplayTryMode at allopts.d:76
frame #2: 0x000000010027dc7a lix`_D6basics5resol21weHaveAReasonToChangeFZb at resol.d:54
frame #3: 0x000000010027dbad lix`_D6basics5resol36changeResolutionBasedOnUserFileAloneFZv at resol.d:46
frame #4: 0x000000010028049a lix`_D6basics8mainloop8MainLoop23toMainMenuWithResChangeMFZv(this=0x000000010163b980) at mainloop.d:375
frame #5: 0x000000010027fa77 lix`_D6basics8mainloop8MainLoop4calcMFZv(this=0x000000010163b980) at mainloop.d:299
frame #6: 0x0000000100075e70 lix`_D6basics8mainloop8MainLoop8mainLoopMFZv(this=0x000000010163b980) at mainloop.d:106
frame #7: 0x0000000100075b5a lix`_D4mainQfFAAyaZ9__lambda2MFZi at main.d:38
frame #8: 0x00000001002a797d lix`_D8allegro56system14al_run_allegroFMDFZiZ11main_runnerUiPPaZi(argc=0, argv=0x00007ffeefbff3f8) at system.d:24
frame #9: 0x00000001012535a3 liballegro.5.2.dylib`call_user_main + 23
frame #10: 0x000000010125358c liballegro.5.2.dylib`+[AllegroAppDelegate app_main:] + 9
frame #11: 0x00007fff327da87e Foundation`__NSThread__start__ + 1194
frame #12: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #13: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #14: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #6, name = 'com.apple.NSEventThread'
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff3058f13e CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff3058e6ac CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff3058de0e CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00007fff2dc1cd1a AppKit`_NSEventThread + 175
frame #6: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #7: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #8: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #7
frame #0: 0x00007fff5cb3ef32 libsystem_kernel.dylib`__semwait_signal + 10
frame #1: 0x00007fff5caca914 libsystem_c.dylib`nanosleep + 199
frame #2: 0x0000000101253b81 liballegro.5.2.dylib`al_rest + 55
frame #3: 0x000000010121ec77 liballegro.5.2.dylib`timer_thread_proc + 185
frame #4: 0x0000000101253ca5 liballegro.5.2.dylib`thread_proc_trampoline + 11
frame #5: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #6: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #7: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #9
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #10
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf3636 libsystem_pthread.dylib`_pthread_wqthread + 458
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #11
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #12
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff3058f13e CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff3058e6ac CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff3058de0e CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00000001011b914a liballegro_audio.5.2.dylib`stream_proc + 392
frame #6: 0x000000010121e399 liballegro.5.2.dylib`detached_thread_func_trampoline + 22
frame #7: 0x0000000101253ca5 liballegro.5.2.dylib`thread_proc_trampoline + 11
frame #8: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #9: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #10: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #13
frame #0: 0x00007fff5cb3b27e libsystem_kernel.dylib`semaphore_timedwait_trap + 10
frame #1: 0x00007fff5c9b9c99 libdispatch.dylib`_dispatch_sema4_timedwait + 76
frame #2: 0x00007fff5c9ba378 libdispatch.dylib`_dispatch_semaphore_wait_slow + 58
frame #3: 0x00007fff5c9c71fd libdispatch.dylib`_dispatch_worker_thread + 317
frame #4: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #5: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #6: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #14, name = 'AQConverterThread'
frame #0: 0x00007fff5cb3e86a libsystem_kernel.dylib`__psynch_cvwait + 10
frame #1: 0x00007fff5cbf756e libsystem_pthread.dylib`_pthread_cond_wait + 722
frame #2: 0x00007fff2ef463ea AudioToolbox`CAGuard::Wait() + 72
frame #3: 0x00007fff2ef42795 AudioToolbox`AQConverterManager::AQConverterThread::Run() + 375
frame #4: 0x00007fff2ef42613 AudioToolbox`AQConverterManager::AQConverterThread::ConverterThreadEntry(void*) + 9
frame #5: 0x00007fff2ef1f961 AudioToolbox`CAPThread::Entry(CAPThread*) + 77
frame #6: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #7: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #8: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #15, name = 'com.apple.audio.IOThread.client'
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff30008eda CoreAudio`HALB_MachPort::SendMessageWithReply(unsigned int, unsigned int, unsigned int, unsigned int, mach_msg_header_t*, bool, unsigned int) + 122
frame #3: 0x00007fff30008e4f CoreAudio`HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 45
frame #4: 0x00007fff3000539f CoreAudio`HALC_ProxyIOContext::IOWorkLoop() + 1017
frame #5: 0x00007fff30004df4 CoreAudio`HALC_ProxyIOContext::IOThreadEntry(void*) + 122
frame #6: 0x00007fff30004956 CoreAudio`HALB_IOThread::Entry(void*) + 72
frame #7: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #8: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #9: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
(lldb)
Thanks for the backtrace, this was extremely helpful! I've updated Lix to 0.9.26, including a fix (I hope) for the crash. Please try to build Lix 0.9.26 (the current master) and see if it still crashes for you!
Interesting that macOS 10.14.4 fixes the black screen. Maybe it really was the macOS bug with OpenGL...
Explanation of the change about the crash: I believe the crash was unrelated to the black screen. The crash happened in my own code that does not call any Allegro functions or other platform-specific functions. From your backtrace:
* thread #5, stop reason = EXC_BAD_ACCESS (code=1, address=0xf)
* frame #0: 0x000000000000000f
frame #1: 0x000000010010e29a displayTryMode at allopts.d:76
frame #2: 0x000000010027dc7a weHaveAReasonToChange at resol.d:54
I'm surprised that there was crash potential at all here -- both from looking at my code, and because this platform-independent code never crashed on Windows or Linux.
For 0.9.26, I've rewritten displayTryMode
to be super-careful and explicit (no return
statements that can throw). It should not crash anymore.
I pulled the latest code but still have the issue:
(lldb) bt all
error: need to add support for DW_TAG_base_type 'immutable(char)' encoded with DW_ATE = 0x10, bit_size = 8
error: need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x10, bit_size = 8
error: need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x10, bit_size = 8
thread #1, queue = 'com.apple.main-thread'
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff3058f13e CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff3058e6ac CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff3058de0e CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00007fff2f87a9db HIToolbox`RunCurrentEventLoopInMode + 292
frame #6: 0x00007fff2f87a715 HIToolbox`ReceiveNextEventCommon + 603
frame #7: 0x00007fff2f87a4a6 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64
frame #8: 0x00007fff2dc14ffb AppKit`_DPSNextEvent + 965
frame #9: 0x00007fff2dc13d93 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
frame #10: 0x00007fff2dc0deb0 AppKit`-[NSApplication run] + 699
frame #11: 0x0000000101485ad7 liballegro.5.2.dylib`_al_osx_run_main + 1312
frame #12: 0x000000010029979c lix`_D8allegro56system14al_run_allegroFMDFZiZi(user_main=int delegate() @ 0x00007ffeefbff400) at system.d:36
frame #13: 0x0000000100073a9b lix`_Dmain(args=string[] @ 0x00007ffeefbff460) at main.d:35
frame #14: 0x000000010041e130 lix`_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 112
frame #15: 0x000000010041df23 lix`_d_run_main + 547
frame #16: 0x00000001000749a5 lix`main(argc=1, argv=0x00007ffeefbff5e8) at __entrypoint.d:8
frame #17: 0x00007fff5ca063d5 libdyld.dylib`start + 1
frame #18: 0x00007fff5ca063d5 libdyld.dylib`start + 1
thread #2
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #3
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #4
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x34c7bb4100005000
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
* thread #5, stop reason = EXC_BAD_ACCESS (code=1, address=0x1e000000000)
* frame #0: 0x000001e000000000
frame #1: 0x00000001001010ff lix`_D4file6option6screen14displayTryModeFNbNdZSQBqQBoQBk14DisplayTryMode at screen.d:36
frame #2: 0x000000010027095a lix`_D6basics5resol21weHaveAReasonToChangeFZb at resol.d:54
frame #3: 0x000000010027087d lix`_D6basics5resol36changeResolutionBasedOnUserFileAloneFZv at resol.d:46
frame #4: 0x000000010027313a lix`_D6basics8mainloop8MainLoop23toMainMenuWithResChangeMFZv(this=0x0000000102238b00) at mainloop.d:375
frame #5: 0x000000010027271e lix`_D6basics8mainloop8MainLoop4calcMFZv(this=0x0000000102238b00) at mainloop.d:299
frame #6: 0x0000000100074770 lix`_D6basics8mainloop8MainLoop8mainLoopMFZv(this=0x0000000102238b00) at mainloop.d:106
frame #7: 0x000000010007445b lix`_D4mainQfFAAyaZ9__lambda2MFZi at main.d:38
frame #8: 0x00000001002997dd lix`_D8allegro56system14al_run_allegroFMDFZiZ11main_runnerUiPPaZi(argc=0, argv=0x00007ffeefbff3f8) at system.d:24
frame #9: 0x00000001014855a3 liballegro.5.2.dylib`call_user_main + 23
frame #10: 0x000000010148558c liballegro.5.2.dylib`+[AllegroAppDelegate app_main:] + 9
frame #11: 0x00007fff327da87e Foundation`__NSThread__start__ + 1194
frame #12: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #13: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #14: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #6, name = 'com.apple.NSEventThread'
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff3058f13e CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff3058e6ac CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff3058de0e CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00007fff2dc1cd1a AppKit`_NSEventThread + 175
frame #6: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #7: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #8: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #7
frame #0: 0x00007fff5cb3ef32 libsystem_kernel.dylib`__semwait_signal + 10
frame #1: 0x00007fff5caca914 libsystem_c.dylib`nanosleep + 199
frame #2: 0x0000000101485b81 liballegro.5.2.dylib`al_rest + 55
frame #3: 0x0000000101450c77 liballegro.5.2.dylib`timer_thread_proc + 185
frame #4: 0x0000000101485ca5 liballegro.5.2.dylib`thread_proc_trampoline + 11
frame #5: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #6: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #7: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #8
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf3636 libsystem_pthread.dylib`_pthread_wqthread + 458
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #9
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #10
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #11
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf3636 libsystem_pthread.dylib`_pthread_wqthread + 458
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #12
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff3058f13e CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff3058e6ac CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff3058de0e CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00000001013eb14a liballegro_audio.5.2.dylib`stream_proc + 392
frame #6: 0x0000000101450399 liballegro.5.2.dylib`detached_thread_func_trampoline + 22
frame #7: 0x0000000101485ca5 liballegro.5.2.dylib`thread_proc_trampoline + 11
frame #8: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #9: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #10: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #13
frame #0: 0x00007fff5cb3b27e libsystem_kernel.dylib`semaphore_timedwait_trap + 10
frame #1: 0x00007fff5c9b9c99 libdispatch.dylib`_dispatch_sema4_timedwait + 76
frame #2: 0x00007fff5c9ba378 libdispatch.dylib`_dispatch_semaphore_wait_slow + 58
frame #3: 0x00007fff5c9c71fd libdispatch.dylib`_dispatch_worker_thread + 317
frame #4: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #5: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #6: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #14, name = 'AQConverterThread'
frame #0: 0x00007fff5cb3e86a libsystem_kernel.dylib`__psynch_cvwait + 10
frame #1: 0x00007fff5cbf756e libsystem_pthread.dylib`_pthread_cond_wait + 722
frame #2: 0x00007fff2ef463ea AudioToolbox`CAGuard::Wait() + 72
frame #3: 0x00007fff2ef42795 AudioToolbox`AQConverterManager::AQConverterThread::Run() + 375
frame #4: 0x00007fff2ef42613 AudioToolbox`AQConverterManager::AQConverterThread::ConverterThreadEntry(void*) + 9
frame #5: 0x00007fff2ef1f961 AudioToolbox`CAPThread::Entry(CAPThread*) + 77
frame #6: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #7: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #8: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #15, name = 'com.apple.audio.IOThread.client'
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff30008eda CoreAudio`HALB_MachPort::SendMessageWithReply(unsigned int, unsigned int, unsigned int, unsigned int, mach_msg_header_t*, bool, unsigned int) + 122
frame #3: 0x00007fff30008e4f CoreAudio`HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 45
frame #4: 0x00007fff3000539f CoreAudio`HALC_ProxyIOContext::IOWorkLoop() + 1017
frame #5: 0x00007fff30004df4 CoreAudio`HALC_ProxyIOContext::IOThreadEntry(void*) + 122
frame #6: 0x00007fff30004956 CoreAudio`HALB_IOThread::Entry(void*) + 72
frame #7: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #8: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #9: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
Hmm, thanks for the crash log.
The crash is still in the same place, even though I've refactored the code to be very explicit. When I look at the crashing function naively, it's impossible to think of a way that this can crash at all (see explanation below).
Speculation: It's possible that we've hit a multithreading issue that only surfaces on Mac. I have ideas to rewrite Lix's initialization code to remove this multithreading problem (again see explanation below).
It's not a large rewrite, but I'd like to be careful and thorough, therefore it'll take a few days. I'll let you know once I have it ready to test!
Technical explanation. The crash is in screen.d:36
, which is the if
in this function:
@property DisplayTryMode displayTryMode()
{
if (screenMode is null
|| screenMode.value == ScreenMode.softwareFullscreen
|| screenWindowedX is null
|| screenWindowedY is null
) {
return DisplayTryMode(ScreenMode.softwareFullscreen, 0, 0);
}
return DisplayTryMode(userScreenModeOrDefault,
screenWindowedX.value, screenWindowedY.value);
}
All three of screenMode
, screenWindowedX
, and screenWindowedY
are class object references. Testing for null should not crash. Operator ||
is short-circuit in D, therefore we won't dereference a null reference. screenMode.value
is a value type and ScreenMode.softwareFullscreen
is a compile-time constant, therefore
The only way for this if
statement to crash is when we access forbidden non-null memory. This might mean that the thread accesses non-shared mutable memory outside his own thread-local memory. (In D, unqualified mutable variables are per-thread by default. Immutable variables are implicitly shared. The programmer can explicitly share mutable variables but I never do that in Lix.)
The class objects (to which screenMode
and the other references are pointing) are initialized during static construction. Static construction happens before main()
is called. Static construction runs all code in static this() { ... }
, which appears, e.g., in allopts.d
to create screenMode
.
I loosely remember that on macOS, either static construction isn't necessarily run by the same thread that will later run main()
, or al_run_main()
from Allegro 5 introduces a fresh thread that is different from static construction or earlier stuff from main()
.
This leads to my speculation of the unwanted multithreading, even though only one thread is running main()
and in there al_run_main()
, which might spawn yet another thread on macOS. In D, all class variables (of all up to 3 involved threads) are initialized to null
. The crash would mean that (the object to which screenMode
points) sits in a different thread A than (the thread B that calls displayTryMode()
), and still -- somehow, I don't understand how -- B's thread-local screenMode
still points to A's thread-local memory. Well, let's see if a rewrite can fix this: I want to move all initialization of the global option variables into al_run_main()
inside main()
.
I've pushed a fix candidate into my unstable Lix repository. Please add the unstable repository and build its branch static-this-avoid
:
git remote add unst https://github.com/SimonN/lix-unstable
git fetch unst static-this-avoid
git checkout unst/static-this-avoid
dub
Does this fix the crash for you?
This fix candidate moves all initialization of mutable objects from module constructors (static this
) into al_run_main
. I hope that this gets around any multithreading problems.
Still failing:
(lldb) bt all
error: need to add support for DW_TAG_base_type 'immutable(char)' encoded with DW_ATE = 0x10, bit_size = 8
error: need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x10, bit_size = 8
error: need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x10, bit_size = 8
thread #1, queue = 'com.apple.main-thread'
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff3058f13e CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff3058e6ac CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff3058de0e CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00007fff2f87a9db HIToolbox`RunCurrentEventLoopInMode + 292
frame #6: 0x00007fff2f87a715 HIToolbox`ReceiveNextEventCommon + 603
frame #7: 0x00007fff2f87a4a6 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64
frame #8: 0x00007fff2dc14ffb AppKit`_DPSNextEvent + 965
frame #9: 0x00007fff2dc13d93 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
frame #10: 0x00007fff2dc0deb0 AppKit`-[NSApplication run] + 699
frame #11: 0x0000000101483ad7 liballegro.5.2.dylib`_al_osx_run_main + 1312
frame #12: 0x000000010029978c lix`_D8allegro56system14al_run_allegroFMDFZiZi(user_main=int delegate() @ 0x00007ffeefbff400) at system.d:36:2
frame #13: 0x000000010007377b lix`_Dmain(args=string[] @ 0x00007ffeefbff460) at main.d:35:9
frame #14: 0x000000010041e120 lix`_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 112
frame #15: 0x000000010041df13 lix`_d_run_main + 547
frame #16: 0x0000000100074685 lix`main(argc=1, argv=0x00007ffeefbff5e8) at __entrypoint.d:8:21
frame #17: 0x00007fff5ca063d5 libdyld.dylib`start + 1
frame #18: 0x00007fff5ca063d5 libdyld.dylib`start + 1
thread #2
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #3
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00000000000186a9
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #4
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
* thread #5, stop reason = EXC_BAD_ACCESS (code=1, address=0x1e000000000)
* frame #0: 0x000001e000000000
frame #1: 0x000000010010117f lix`_D4file6option6screen14displayTryModeFNbNdZSQBqQBoQBk14DisplayTryMode at screen.d:36:5
frame #2: 0x000000010027094a lix`_D6basics5resol21weHaveAReasonToChangeFZb at resol.d:54:5
frame #3: 0x000000010027086d lix`_D6basics5resol36changeResolutionBasedOnUserFileAloneFZv at resol.d:46:5
frame #4: 0x000000010027312a lix`_D6basics8mainloop8MainLoop23toMainMenuWithResChangeMFZv(this=0x0000000101a31a80) at mainloop.d:375:9
frame #5: 0x000000010027270e lix`_D6basics8mainloop8MainLoop4calcMFZv(this=0x0000000101a31a80) at mainloop.d:299:17
frame #6: 0x0000000100074450 lix`_D6basics8mainloop8MainLoop8mainLoopMFZv(this=0x0000000101a31a80) at mainloop.d:106:13
frame #7: 0x000000010007413b lix`_D4mainQfFAAyaZ9__lambda2MFZi at main.d:38:13
frame #8: 0x00000001002997cd lix`_D8allegro56system14al_run_allegroFMDFZiZ11main_runnerUiPPaZi(argc=0, argv=0x00007ffeefbff3f8) at system.d:24:3
frame #9: 0x00000001014835a3 liballegro.5.2.dylib`call_user_main + 23
frame #10: 0x000000010148358c liballegro.5.2.dylib`+[AllegroAppDelegate app_main:] + 9
frame #11: 0x00007fff327da87e Foundation`__NSThread__start__ + 1194
frame #12: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #13: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #14: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #6, name = 'com.apple.NSEventThread'
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff3058f13e CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff3058e6ac CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff3058de0e CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00007fff2dc1cd1a AppKit`_NSEventThread + 175
frame #6: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #7: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #8: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #7
frame #0: 0x00007fff5cb3ef32 libsystem_kernel.dylib`__semwait_signal + 10
frame #1: 0x00007fff5caca914 libsystem_c.dylib`nanosleep + 199
frame #2: 0x0000000101483b81 liballegro.5.2.dylib`al_rest + 55
frame #3: 0x000000010144ec77 liballegro.5.2.dylib`timer_thread_proc + 185
frame #4: 0x0000000101483ca5 liballegro.5.2.dylib`thread_proc_trampoline + 11
frame #5: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #6: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #7: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #8
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf36e6 libsystem_pthread.dylib`_pthread_wqthread + 634
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #9
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf3636 libsystem_pthread.dylib`_pthread_wqthread + 458
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #10
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf3636 libsystem_pthread.dylib`_pthread_wqthread + 458
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #11
frame #0: 0x00007fff5cb3cbfe libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff5cbf3636 libsystem_pthread.dylib`_pthread_wqthread + 458
frame #2: 0x00007fff5cbf33fd libsystem_pthread.dylib`start_wqthread + 13
thread #12
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff3058f13e CoreFoundation`__CFRunLoopServiceMachPort + 328
frame #3: 0x00007fff3058e6ac CoreFoundation`__CFRunLoopRun + 1612
frame #4: 0x00007fff3058de0e CoreFoundation`CFRunLoopRunSpecific + 455
frame #5: 0x00000001013e914a liballegro_audio.5.2.dylib`stream_proc + 392
frame #6: 0x000000010144e399 liballegro.5.2.dylib`detached_thread_func_trampoline + 22
frame #7: 0x0000000101483ca5 liballegro.5.2.dylib`thread_proc_trampoline + 11
frame #8: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #9: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #10: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #13
frame #0: 0x00007fff5cb3b27e libsystem_kernel.dylib`semaphore_timedwait_trap + 10
frame #1: 0x00007fff5c9b9c99 libdispatch.dylib`_dispatch_sema4_timedwait + 76
frame #2: 0x00007fff5c9ba378 libdispatch.dylib`_dispatch_semaphore_wait_slow + 58
frame #3: 0x00007fff5c9c71fd libdispatch.dylib`_dispatch_worker_thread + 317
frame #4: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #5: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #6: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #14, name = 'AQConverterThread'
frame #0: 0x00007fff5cb3e86a libsystem_kernel.dylib`__psynch_cvwait + 10
frame #1: 0x00007fff5cbf756e libsystem_pthread.dylib`_pthread_cond_wait + 722
frame #2: 0x00007fff2ef463ea AudioToolbox`CAGuard::Wait() + 72
frame #3: 0x00007fff2ef42795 AudioToolbox`AQConverterManager::AQConverterThread::Run() + 375
frame #4: 0x00007fff2ef42613 AudioToolbox`AQConverterManager::AQConverterThread::ConverterThreadEntry(void*) + 9
frame #5: 0x00007fff2ef1f961 AudioToolbox`CAPThread::Entry(CAPThread*) + 77
frame #6: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #7: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #8: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
thread #15, name = 'com.apple.audio.IOThread.client'
frame #0: 0x00007fff5cb3b22a libsystem_kernel.dylib`mach_msg_trap + 10
frame #1: 0x00007fff5cb3b76c libsystem_kernel.dylib`mach_msg + 60
frame #2: 0x00007fff30008eda CoreAudio`HALB_MachPort::SendMessageWithReply(unsigned int, unsigned int, unsigned int, unsigned int, mach_msg_header_t*, bool, unsigned int) + 122
frame #3: 0x00007fff30008e4f CoreAudio`HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 45
frame #4: 0x00007fff3000539f CoreAudio`HALC_ProxyIOContext::IOWorkLoop() + 1017
frame #5: 0x00007fff30004df4 CoreAudio`HALC_ProxyIOContext::IOThreadEntry(void*) + 122
frame #6: 0x00007fff30004956 CoreAudio`HALB_IOThread::Entry(void*) + 72
frame #7: 0x00007fff5cbf42eb libsystem_pthread.dylib`_pthread_body + 126
frame #8: 0x00007fff5cbf7249 libsystem_pthread.dylib`_pthread_start + 66
frame #9: 0x00007fff5cbf340d libsystem_pthread.dylib`thread_start + 13
(lldb) quit
Thanks. Hmm, that leaves me out of explanations.
I've peppered the crashing code with lots of printf debugging: Delete user/options.sdl
if it exists. Then pull the branch static-this-avoid once more from the unstable repository:
git remote add unst https://github.com/SimonN/lix-unstable
git fetch unst static-this-avoid
git checkout unst/static-this-avoid
Build and run Lix:
dub
...and show the standard output from console.
After that, here are more ideas:
Idea 1. Start a level directly from the command line (bypassing username entry menu, main menu, and level browser): $ bin/lix levels/single/lemforum/Lovely/anyway.txt
. Does this crash or run?
Idea 2. In Lix's root directory, create the directory user
and in it the text file options.sdl
with the following content (if the file already exists, delete everything in it first):
userName "Xyz"
screenMode 0
screenWindowedX 640
screenWindowedY 480
This bypasses the username entry menu (because you already provide a name) and goes directly to the main menu. Does this crash or run?
Idea 3. Install the DMD compiler with $ brew install dmd
and see if Lix still crashes when you build it with DMD instead of LDC. To build with DMD, run $ dub --compiler=dmd
. To build with LDC as before, run $ dub --compiler=ldc2
.
Even if one of these ideas works for you, I'd still like your standard console output of the current branch static-this-avoid from the unstable Lix repository. :-)
Hi @MartinDelille, have you had the time to build static-this-avoid
again (as described in previous post)?
Since April 2019, both DMD and Lix updated. Maybe Lix 0.9.28 has begun working in the meantime by luck.
It's also fine if you don't want to spend more time on this. Your issue report was very good already. I merely can't test on Macs myself and must assume that Lix still crashes/shows black screen on Mac.
namida tried to build on MacOS Catalina: https://www.lemmingsforums.net/index.php?topic=4175.msg77616#msg77616
This bug prevented building: https://issues.dlang.org/show_bug.cgi?id=20019
I tried with both LDC and DMD; same results either way. I then tried removing BOTH compilers just in case - and sure enough, I still get the error, so it appears to be with Dub, not with the compilers. Quick Googling suggests this is a general issue with D compilers on Mac OS X Catalina, and not specific to Lix in any way. We'll need to try this again when a update exists (or when the update is integrated into Brew, or when I can be bothered doing this outside of Brew, etc).
I replied:
Thanks for the exhaustive testing! Interesting that the bugfix merge in July 2019 hasn't made it into Brew yet. Let's see what happens.
It's perfectly fine to wait now, you can try again in a couple months. The 3 most common D compilers (dmd, ldc, gdc) all have the same frontend for parsing D, and then different backends for code generation. DMD gets updates the quickest.
At least Brew is cutting edge. Brew's dub 1.17.0 is current, github dub is 1.17.0. Dub homepage is 1.11.0, outdated :-P Brew's DMD at 2.088.1 is also cutting edge, very nice.
Thus, we have a completely different issue that blocks testing. We can't yet check whether #381 still manifests (as in Jan-Apr 2019) or has already vanished (due to the resolved OSX/OpenGL bug).
Closing this because Benedict (new player, I exchanged some email with him) got it running perfectly on the Mac.
I'm happy that Lix compiles and runs well on the Mac now, even though we've never found the true reason for this #381. SiegeLord was happy to chalk an Allegro problem up to a known 2018 bug on OSX. Given that, I'm content closing this, hoping that the same Mac bugfix also fixed this #381.
If anybody runs into troubles on Mac again, feel free to file new bugs!
I tried to compile and run LixD thanks to the instruction here: https://github.com/SimonN/LixD/blob/master/doc/build/linux.md
The music plays and the following window opens:
Unfortunately, my computer almost freeze (turns very unresponsive) and the app finally crash with this error message:
Any way to have some more detailed log?