|
Sporadic exception EXC_I386_SGL using Visual Studio Code on a Mac |
Onewing
Member #6,152
August 2005
|
I have a small program that I built that puts a pink box on the display. When I run it, I sometimes get the following exception: {"name":"611058","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/c\/6cf64dde34af5d77d2f96f5e7cf51cab.png","w":438,"h":159,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/c\/6cf64dde34af5d77d2f96f5e7cf51cab"} Sometimes I don't. Then the pink box appears and all is fine, like this: {"name":"611059","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/2\/42fdc1f098fb17508a2a206198c2c14a.png","w":659,"h":512,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/2\/42fdc1f098fb17508a2a206198c2c14a"} But if I just keep debugging the program, I eventually (maybe 2 or 3 times) get the exception above. And, if I tell VS Code to keep running the program after the exception, I get a black display with no pink box. Sometimes this display is unresponsive. One time the whole mac froze and I had to restart. I'm not sure what could be wrong and looking for clues. Here's the full code of the application. Although, considering it sometimes works, I have a feeling it's not the code and something obscure that needs to be configured on the Mac. 1#define ALLEGRO_NO_MAGIC_MAIN
2#include <allegro5/allegro.h>
3#include <iostream>
4using namespace std;
5
6const int BOUNCER_SIZE = 32;
7
8int real_main(int argc, char **argv)
9{
10 ALLEGRO_DISPLAY *display = NULL;
11
12 if (!al_init())
13 {
14 fprintf(stderr, "failed to initialize allegro!\n");
15 return -1;
16 }
17
18 display = al_create_display(640, 480);
19 if (!display)
20 {
21 fprintf(stderr, "failed to create display!\n");
22 return -1;
23 }
24
25
26 ALLEGRO_BITMAP *bouncer = NULL;
27 bouncer = al_create_bitmap(BOUNCER_SIZE, BOUNCER_SIZE);
28 if (!bouncer)
29 {
30 fprintf(stderr, "failed to create bouncer bitmap!\n");
31 al_destroy_display(display);
32 return -1;
33 }
34 al_set_target_bitmap(bouncer);
35 al_clear_to_color(al_map_rgb(255, 0, 255));
36 al_set_target_bitmap(al_get_backbuffer(display));
37
38 while (1)
39 {
40
41 al_clear_to_color(al_map_rgb(0, 0, 0));
42 al_draw_bitmap(bouncer, 100, 100, 0);
43 al_flip_display();
44 }
45
46 al_destroy_display(display);
47
48 return 1;
49}
50
51int main(int argc, char **argv)
52{
53 return al_run_main(argc, argv, real_main);
54}
------------ |
beoran
Member #12,636
March 2011
|
Strange, looks like it should work. The only thing I can think of is that you might be linking against the wrong version of Allegro. Would that be possible? |
SiegeLord
Member #7,827
October 2006
|
Sounds reminiscent of https://github.com/liballeg/allegro5/issues/798, we're still investigating (I'm having trouble getting this to reproduce on my mac). EDIT: Actually... did you install via homebrew? I see this stackoverflow issue that seems similar to yours: https://stackoverflow.com/questions/20114920/can-an-exec-bad-instruction-sigill-on-dyld-my-fault and https://github.com/Homebrew/legacy-homebrew/issues/38814 "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Onewing
Member #6,152
August 2005
|
Updated this post at the bottom. Thanks, SiegeLord and beoran! I appreciate the thoughts/suggestions. I tried to uninstall allegro via homebrew and install again with "brew install --build-bottle allegro." I got the same results. I'll have some time tomorrow to play around with this more and will read those articles a little closer. At this point, I'm trying to rule things out. Things I'm thinking of:
Other things I should look into? *** Edit on 9.27.17*** ------------ |
beoran
Member #12,636
March 2011
|
Could you link with the debug version of Allegro and then trace into the ogl_flush_vertex_cache function to see if anything is wrong there? Also, is it possible on OSX that the bitmap gets "lost" like on Windows? |
SiegeLord
Member #7,827
October 2006
|
Hold on... do you have a backtrace for that other exception? Is it similar to this one? "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Onewing
Member #6,152
August 2005
|
Here's what I see on the call stack for the original exception I posted: {"name":"611065","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/3\/e3ff352ebf58897ee70444693cd4de52.png","w":952,"h":220,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/3\/e3ff352ebf58897ee70444693cd4de52"} Beoran, how do I "link with the debug version"? Here's how I compile the app: 1g++ -g helloworld.cpp -Wall -ansi -o test20 -L/usr/local/lib/ -I/usr/local/include/ -lallegro
------------ |
beoran
Member #12,636
March 2011
|
Does brew provide a debug version of Allegro? Otherwise you'll probably have to compile it yourself. |
Onewing
Member #6,152
August 2005
|
@beoran, I am not sure. I was unable to find any documentation on this or how to go about it. Update: {"name":"611066","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/6\/364b284b5e37af8ebefffa90e824fa9e.png","w":519,"h":362,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/6\/364b284b5e37af8ebefffa90e824fa9e"} ------------ |
beoran
Member #12,636
March 2011
|
Hmm, this is really strange behaviour. I found the link above, for what it is worth, but it seems weird that the exception is in different functions. |
Onewing
Member #6,152
August 2005
|
It is strange...but maybe not that strange? I used VS Code option to remove all breakpoints, even though I didn't have any I had set. No change in behavior. I opened up my work Mac laptop and did the following: Installed homebrew At this point, it feels like it has to do with Mac, VS Code or allegro 5.2.2. ------------ |
SiegeLord
Member #7,827
October 2006
|
Some good news. I installed VS Code on my mac, tried your code and indeed, I get EXC_I386_SGL sporadically when I run it. However, I get no issues if I run the program manually from the command line or finder. So far, it seems like some VS Code/lldb/allegro issue. This is separate from your other problems, but those now again sound like the bug I linked in the other thread: https://github.com/liballeg/allegro5/issues/798 Can you see if you can find the same system logs the person in that bug is looking at? I'll keep working on it on my end, meanwhile. I really want to fix this, and I appreciate your keeping at it. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Onewing
Member #6,152
August 2005
|
Thanks, SiegeLord. I appreciate you sticking with me. I did three runs (all were bad runs) and captured Console messages plus a set of messages right after. They are all attached. What I see is each run had the following: And shortly after that, there would be a message from the kernel process: [Update: 10-4-17] I still get the deprecated calls above in the Console when running the app. Technically, according to this, I think this should be resolved. ------------ |
SiegeLord
Member #7,827
October 2006
|
Huh! That's a bit anti-climatic. Was that 10 times in a row until a crash or 10 times and you got satisfied? "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Onewing
Member #6,152
August 2005
|
10 times with no crash, more than 3x the max I could go before. So I'm feeling pretty confident. Tomorrow, I'm going to run through the other allegro 5 API tutorials to get a refresher. Fingers crossed this doesn't come back. I haven't upgraded my work laptop and the error still happens there. If you wanted me to try any kind of patch, I could test it out on that machine. ------------ |
SiegeLord
Member #7,827
October 2006
|
Unfortunately I am still nowhere closer to figuring out what exactly could cause this. It'd really be nice to know which operation actually causes this (is it display creation? bitmap creation? one of the drawing commands?). If you could log how far the program gets before it crashes, I think that would be illuminating. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
beoran
Member #12,636
March 2011
|
I checked but the osx GL driver uses way too few ALLEGRO_DEBUG statements. We would have to add quite a few of them to get useful logging. |
|