Search code examples
c++allegromacos-catalina

Allegro5 al_create_display() crash on Mac OS Catalina


I am experiencing the following problem: I am able to compile my allegro application with a make file without errors, however when I run the ./file I get a "zsh: illegal hardware instruction ./file" message. I commented out some parts of the code and it seems that the issue is cause (or perhaps this is only one of the casuses) by the al_create_display() function.

I replicated the problem with a very simple allegro program (basically just opening a display).

My allegro is installed with homebrew and I compile the program with g++-9. The machine I used was a MacBook Pro from 2016, 13inch no touchbar. The system was Mac OS Catalina. Before the update to Catalina no such problems had occured.

Some information from the crash report:

Crashed Thread: 3

Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [1579]

Application Specific Information:
-[NSOpenGLContext update] must be called from the main thread if the context has a view.

And the thread that crashed:
Thread 3 Crashed:
0 com.apple.AppKit 0x00007fff3a4878a1 -[NSOpenGLContext update] + 520
1 liballegro.5.2.dylib 0x0000000102876943 create_display_win + 1079
2 liballegro.5.2.dylib 0x000000010283b3d4 al_create_display + 40
3 file 0x0000000102724e72 Display::Display() + 130
4 file 0x0000000102724f22 Display::instance() + 62
5 file 0x00000001026e2f4f _al_mangled_main + 508
6 liballegro.5.2.dylib 0x0000000102878d47 call_user_main + 23
7 liballegro.5.2.dylib 0x0000000102878d30 +[AllegroAppDelegate app_main:] + 9
8 com.apple.Foundation 0x00007fff3f58cef2 NSThread__start + 1064
9 libsystem_pthread.dylib 0x00007fff74405d76 _pthread_start + 125
10 libsystem_pthread.dylib 0x00007fff744025d7 thread_start + 15

Solution

  • The problem has been addressed by the developers of the library: https://github.com/liballeg/allegro5/issues/1091. The current version on the main branch does not cause the problem. I have tried it myself and everything appears to work. The only thing is that you have to build allegro manually using cmake or xcode. I don't know when the brew version will be updated.