Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Direct3D with Display Events does not shut down

This thread is locked; no one can reply to it. rss feed Print
Direct3D with Display Events does not shut down
Matthew Leverton
Supreme Loser
January 1999
avatar

The following code randomly fails to shut down with MSVC 8 and Allegro 4.9.12 (binaries from allegro5.org):

#SelectExpand
1#include <allegro5/allegro.h> 2#include <allegro5/a5_opengl.h> 3#include <allegro5/a5_direct3d.h> 4 5int main() 6{ 7 al_init(); 8 al_install_keyboard(); 9 10 al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_DIRECT3D); 11 12 ALLEGRO_DISPLAY *display = al_create_display(640, 480); 13 14 ALLEGRO_EVENT_QUEUE *queue = al_create_event_queue(); 15 al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE *)display); 16 17 ALLEGRO_EVENT event; 18 al_wait_for_event(queue, &event); 19 20 al_destroy_event_queue(queue); 21 22 al_destroy_display(display); 23 24 al_uninstall_system(); 25 26 return 0; 27} 28END_OF_MAIN()

Sometimes it shuts down correctly, but when it fails, it appears to never return from the call to al_destroy_event_queue(queue);. The problem does not seem to exist when using the OpenGL driver or when not attaching display events.

Trent Gamblin
Member #261
April 2000
avatar

I just ran that program about 15 times and it didn't hang for me. How often does it hang? What OS? Are you just pressing the close button? I also ran it through Memory Validator and didn't see any problems or hangs.

Matthew Leverton
Supreme Loser
January 1999
avatar

Windows 7 64-bit. Over 95% of the time it hangs after pressing the close button.

The window disappears, but the process is still running at 0% CPU usage. If I break out of the debugger, MSVC 8 has a green arrow next to the al_destroy_display() line. If I resume the debugger, then the program terminates successfully.

Even when running in release mode without a debugger, it hangs.

Trent Gamblin
Member #261
April 2000
avatar

I will try it on Windows 7 32 bit but I don't have 64 to try.

...

Works fine here. I am not running it from VS however. I compiled it with VS 2008 but I'm running it from cmd.exe. It returns every time. Does it still not work if you run it from cmd.exe or Explorer? Check for whatever.exe in your process list after running it a few times.

Matthew Leverton
Supreme Loser
January 1999
avatar

It happens outside of VS 2008 as well. I also was able to duplicate it on my Windows 7 64-bit laptop using my own compiled version of Allegro. However, the problem doesn't occur (as far as I could tell) when running the debug version of Allegro.

Trent Gamblin
Member #261
April 2000
avatar

I think I was a little overzealous when I went memory leak hunting and I think I made a mistake. Not sure this is your problem but try the attached patch.

Matthew Leverton
Supreme Loser
January 1999
avatar

Still has the same behavior.

Go to: