![]() |
|
Program locks on exit (linux only) |
Michael Weiss
Member #223
April 2000
|
My project freezes when I exit in linux only. I have to either kill it with the allegro special death key combo CTRL-ALT-END I have tried all kind of different options in Code::Blocks... I am pretty sure I am shutting down allegro properly And the exact same code works fine on the windows version. Any thoughts or suggestions?
|
Mark Oates
Member #1,146
March 2001
![]() |
Do you have a minimal code example that reproduces the problem? If you have a complex codebase and it's too complicated to isolate, you might std::cout some message (with std::flush), between each point of destruction. If the lock is happening after the last return in main, I would guess you have resources in the global space that were not properly freed, or properly uninitialized, or were initialized or created out of sequence from the sequence of destruction. Also, In the past I've found that I had objects that are being destructed in multiple places, or, had object trees that would loop through destruction of their children and get caught in some recursive or infinite loop. Those are my thoughts, unfortunately I don't know exactly what to suggest unless I had a reproducible example. |
Michael Weiss
Member #223
April 2000
|
Yes, I agree with you.
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Try debugging it with gdb or valgrind. With gdb, you can CTRL-C when it gets stuck and see where it is. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Michael Weiss
Member #223
April 2000
|
I finally figured out how to use gdb to get a trace: (gdb) bt I am not sure what this means...I think it means it is freezing basically the last lines in my code are: printf("al_destroy_event_queue(event_queue)\n"); al_destroy_event_queue(event_queue); printf("\nBefore al_uninstall_system()\n"); al_uninstall_system(); printf("\nAfter al_uninstall_system()\n"); It never prints the line after al_uninstall_system(); Does anyone have any insights or suggestions on other things I could try? Update: I have done some more debugging: In the allegro source I edited event.c 1
2void al_destroy_event_queue(ALLEGRO_EVENT_QUEUE *queue)
3{
4 printf("deq 1\n");
5 ASSERT(queue);
6 printf("deq 2\n");
7 _al_unregister_destructor(_al_dtor_list, queue->dtor_item);
8 /* Unregister any event sources registered with this queue. */
9 while (_al_vector_is_nonempty(&queue->sources)) {
10 ALLEGRO_EVENT_SOURCE **slot = _al_vector_ref_back(&queue->sources);
11 al_unregister_event_source(queue, *slot);
12 }
13 printf("deq 3\n");
14 ASSERT(_al_vector_is_empty(&queue->sources));
15 _al_vector_free(&queue->sources);
16 printf("deq 4\n");
17 ASSERT(queue->events_head == queue->events_tail);
18 _al_vector_free(&queue->events);
19 printf("deq 5\n");
20 _al_cond_destroy(&queue->cond);
21 printf("deq 6\n");
22 _al_mutex_destroy(&queue->mutex);
23 printf("deq 7\n");
24 al_free(queue);
25 printf("deq 8\n");
26}
Now when I run my program I can see exactly how far it got: Purple Martians Version 7.10 Before al_uninstall_system() This is my code where I clean up before exit 1
2void final_wrapup(void)
3{
4 save_display_window_position();
5
6 printf("al_uninstall_audio()\n");
7 al_uninstall_audio();
8
9 printf("al_destroy_font()\n");
10 al_destroy_font(font);
11 al_destroy_font(f1);
12 al_destroy_font(f2);
13 al_destroy_font(f3);
14
15 printf("al_shutdown_ttf_addon()\n");
16 al_shutdown_ttf_addon();
17
18 printf("al_shutdown_font_addon()\n");
19 al_shutdown_font_addon();
20
21 printf("al_shutdown_image_addon()\n");
22 al_shutdown_image_addon();
23
24 printf("al_shutdown_native_dialog_addon()\n");
25 al_shutdown_native_dialog_addon();
26
27 printf("al_shutdown_primitives_addon()\n");
28 al_shutdown_primitives_addon();
29
30 printf("al_unregister_event_source(event_queue, al_get_keyboard_event_source())\n");
31 al_unregister_event_source(event_queue, al_get_keyboard_event_source());
32
33 printf("al_uninstall_keyboard()\n");
34 al_uninstall_keyboard();
35
36 printf("al_unregister_event_source(event_queue, al_get_mouse_event_source())\n");
37 al_unregister_event_source(event_queue, al_get_mouse_event_source());
38
39 printf("al_uninstall_mouse()\n");
40 al_uninstall_mouse();
41
42 printf("al_unregister_event_source(event_queue, al_get_joystick_event_source())\n");
43 al_unregister_event_source(event_queue, al_get_joystick_event_source());
44
45 printf("al_uninstall_joystick()\n");
46 al_uninstall_joystick();
47
48 printf("al_unregister_event_source(event_queue, al_get_timer_event_source(mnu_timer));\n");
49 al_unregister_event_source(event_queue, al_get_timer_event_source(mnu_timer));
50
51 printf("al_unregister_event_source(event_queue, al_get_display_event_source(display))\n");
52 al_unregister_event_source(event_queue, al_get_display_event_source(display));
53
54 printf("al_destroy_display()\n");
55 al_destroy_display(display);
56
57 printf("al_destroy_event_queue(event_queue)\n");
58 al_destroy_event_queue(event_queue);
59
60 printf("\nBefore al_uninstall_system()\n");
61 al_uninstall_system();
62 printf("\nAfter al_uninstall_system()\n");
63}
I used to just have the one line...al_uninstall_system(); I added all the other to troubleshoot this freezing problem If I comment them all out so only al_uninstall_system(); is called, this is what I get: Purple Martians Version 7.10 Before al_uninstall_system() It looks like the first call to al_destroy_event_queue(event_queue); works when I call it explicitly. But when al_uninstall_system() calls it, it dies... I tried to look up the function at the line it dies at: _al_cond_destroy(&queue->cond); But I am way out of my depth here...I could not make sense of anything Could someone much smarter than I have a look and see?
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
You're getting closer. The backtrace doesn't show argument values for some reason. Were both allegro and your game compiled with debugging symbols? Since your game is freezing, it's likely a deadlock in the destruction code. Other useful commands in gdb : info threads thread apply all bt thread # frame # You should take a look at where the other threads are when you hit CTRL-C. Likely another thread is waiting in al_cond_wait . My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Michael Weiss
Member #223
April 2000
|
I think I have all the debugging enabled: Allegro: remade the library... In the game: I ran gdb again and bt and where did not show anything new I ran 'info threads' and 'thread apply all bt' I got a lot more output, but nothing I can make sense of: $ gdb ./pm For help, type "help". Purple Martians Version 7.10
from /lib/x86_64-linux-gnu/libc.so.6
(gdb) thread apply all bt Thread 14 (Thread 0x7fffe1764700 (LWP 728699) "pm"): Thread 13 (Thread 0x7fffe1f65700 (LWP 728698) "pm"): Thread 12 (Thread 0x7fffe2766700 (LWP 728697) "threaded-ml"): Thread 11 (Thread 0x7fffe2f67700 (LWP 728696) "pm"): Thread 10 (Thread 0x7fffe37fe700 (LWP 728695) "pm"): Thread 9 (Thread 0x7fffe8b96700 (LWP 728694) "pm"): Thread 8 (Thread 0x7fffe9541700 (LWP 728693) "gdbus"): Thread 7 (Thread 0x7fffe9d42700 (LWP 728692) "gmain"): Thread 6 (Thread 0x7fffeae01700 (LWP 728691) "pm:disk$3"): Thread 5 (Thread 0x7fffeb602700 (LWP 728690) "pm:disk$2"): Thread 4 (Thread 0x7fffe3fff700 (LWP 728689) "pm:disk$1"): Thread 3 (Thread 0x7fffebe03700 (LWP 728688) "pm:disk$0"): Thread 2 (Thread 0x7ffff4ca7700 (LWP 728683) "pm"): Thread 1 (Thread 0x7ffff4ca8cc0 (LWP 728679) "pm"): UPDATE: From the clues above (pulseaudio and kcm_stream) I started looking at audio... When I commented out all my audio references the program exits clean! I think I know where the problem is now.... Yes! I was not destroying an audio stream I had created...I feel so dumb... Well at least I learned a few things about how to debug....
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
There are lots of threads started with clone. I don't think you have to worry about those. The timer thread is still running, as well as two audio threads. What happens if you don't call al_uninstall_system at all? It should still be registered with atexit if you use al_init to initialize allegro. I have Ubuntu 18.04 running in a VM. I could debug it there if you can provide src or binaries. UPDATE My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Mark Oates
Member #1,146
March 2001
![]() |
Michael Weiss said: I think I know where the problem is now.... Yes! I was not destroying an audio stream I had created...I feel so dumb... OMG YAAAY! Congrats. I was worried about this. You seem to have put a lot of time/effort into whatever it is you're working on. I'm curious, what's your project? |
Michael Weiss
Member #223
April 2000
|
My project is Purple Martians I started it in 1997 with Allegro 2.2 It works identically in windows and linux. The most difficult and rewarding thing I did with it is the networked multiplayer. I recently just figured out how to use github for hosting webpages. Here is my project page on allegro.cc:
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
I played a ton of Purple Martians on Windows until it just got too hard for me to keep up somewhere around 3/4 of the way through the game. Lots of hours of enjoyment though, figuring out the levels and having fun with the game mechanics. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Mark Oates
Member #1,146
March 2001
![]() |
What are you playing with usually? Keyboard/Mouse? Joystick? |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
I played exclusively with keyboard. I usually don't use mouse or joystick unless it's a FPS or flight sim. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Michael Weiss
Member #223
April 2000
|
Thanks Edgar. That means a lot to me that you enjoyed the gameplay! I am currently designing a bunch of new levels. There were too many boring places where you retrace you steps many times to kill every last enemy. I always thought there was so much more that I could do with level design... I like the puzzle based ones, kind of like the portal test chambers. But unlike portal, you have to kill things also... I exclusively play with the keyboard. IJKL for direction, space for jump and C for fire. That is just where my hands naturally fall on the keyboard.
|
Mark Oates
Member #1,146
March 2001
![]() |
You know, just a few days ago I stumbled upon some good level design tutorial/tips graphics on pinterest. Here's an example: {"name":"613140","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/9\/49ccd3071d8c37ed093d241bc8fdfb6b.jpg","w":2112,"h":1188,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/9\/49ccd3071d8c37ed093d241bc8fdfb6b"} It's this guy Tommy Norberg (site) who has made his entire brand just around level design and level design education. He focuses almost entirely on competition style levels (fps or pvp) because, apparently, that's where all the hottest design theory is. He has a twitter, you might check out his pics on google for inspiration. Any one of those could spark an entire idea for level design. |
|