|
Return code 1 |
Aikei_c
Member #14,871
January 2013
|
After my application ends, it returns 1 which should mean that something isn't right. However, I can't tell what it is. d3d D d3d_disp.cpp:904 d3d_destroy_display_internals [ 41.01223] waiting for display 00327FF0's thread to end is this the cause that code 1 is returned? and if so, what is it caused by? I guess that something still referencing d3d device has to do with it. But what? Should I destroy all the bitmaps before destroying the allegro_display? or vice versa? and what about the fonts? |
Trent Gamblin
Member #261
April 2000
|
Do you have a return statement in your main function?
|
Aikei_c
Member #14,871
January 2013
|
No. And it's void main() anyway. I guess allegro substitutes it for something and it's allegro's return code, not mine. |
Dizzy Egg
Member #10,824
March 2009
|
---------------------------------------------------- |
Aikei_c
Member #14,871
January 2013
|
What's funny here, Dizzy Egg? |
Dizzy Egg
Member #10,824
March 2009
|
What did you expect if you declare your main as void? A nice '0' to be returned???
---------------------------------------------------- |
Arvidsson
Member #4,603
May 2004
|
void main is invalid C/C++[1].
|
Aikei_c
Member #14,871
January 2013
|
Well. Thank you very much for noting that. I changed that. |
Trent Gamblin
Member #261
April 2000
|
It's not the d3d thing, that's just a warning. You say you're seeing the return code of 1 in the debugger? What else does the debugger say? Is there a crash or an assertion or exception thrown?
|
Aikei_c
Member #14,871
January 2013
|
No. No crash and nothing is mentioned. That's why I went to allegro.log and that's the only thing that I found here which seemed abnormal. The thread 0x934 has exited with code 0 (0x0). |
Arthur Kalliokoski
Second in Command
February 2005
|
How about putting a message box or a printf("bye\n"); just before that final return 0? Does it show that message on exit? Of course you'd have to run it from a console to see a printf. They all watch too much MSNBC... they get ideas. |
Aikei_c
Member #14,871
January 2013
|
I'm pretty sure it runs up to the very end and executes every last line. UPDATE: I attached allegro.log to the first post. |
Audric
Member #907
January 2001
|
Could be a signal handler called "on exit" because a SIGSEGV happens for example and/or something installed by atexit() crashes. Can you try putting a breakpoint on libc's exit() ? If something is calling exit(1), you'd see in the call stack. |
Aikei_c
Member #14,871
January 2013
|
Hello, Audric and thank you for your input. UPDATE: OK, I did it this way: I made an empty function, put a breakpoint on it and then passed it to atexit(). I'm not sure I put the breakpoint when you suggested, though. |
Trent Gamblin
Member #261
April 2000
|
Try setting a breakpoint anywhere after your program starts up fully. Check which threads are running (don't know how in VS, but should be possible.) Not their id/address and what they're doing. Then when the app exits check which thread that returns 1 corresponds to the one you checked on earlier.
|
Audric
Member #907
January 2001
|
Your test already shows that the issue happens after main() returns, after it executes the function you hooked on atexit(). Maybe then it executes another atexit() function that was registered before yours (by a library, usually). |
Aikei_c
Member #14,871
January 2013
|
Trent Gamblin 2928 0 Main Thread name: Mirrord.exe!MirrorApp::Init Normal 5676 0 Worker Thread name: GdiPlus.dll!DllRefCountSafeThreadThunk() location: GdiPlus.dll!BackgroundThreadProc Normal 1556 0 Worker Thread name: msvcr110d.dll!_threadstartex location: allegro-5.0.8-monolith-md-debug.dll!501c453e Normal 5684 0 Worker Thread name: nvd3dum.dll thread location: nvd3dum.dll!67319d84 Above Normal When the program ends, the 0x162c thread returns with code 1, that is the second thread 5676. Audric UPDATE: |
Trent Gamblin
Member #261
April 2000
|
Can you set a breakpoint in _al_shutdown_gdiplus? What happens if you don't init the image addon?
|
Aikei_c
Member #14,871
January 2013
|
If I don't init the image addon the return code is 0. Gdiplus::GdiplusShutdown(gdiplusToken); the gdiplusToken is 37445138 |
Trent Gamblin
Member #261
April 2000
|
I'm not sure why the GdiPlus thread is returning 1. A temporary solution might be to call al_shutdown_image_addon before returning from main.
|
Aikei_c
Member #14,871
January 2013
|
Shutting image addon down manually doesn't kill the gdi thread and it still only gets destroyed at exit (with code 1). Maybe some other addon uses it too? |
Trent Gamblin
Member #261
April 2000
|
What about a patch like this? diff --git a/addons/image/iio.c b/addons/image/iio.c index d98716e..6ecbfe5 100644 --- a/addons/image/iio.c +++ b/addons/image/iio.c @@ -128,6 +128,10 @@ bool al_init_image_addon(void) void al_shutdown_image_addon(void) { iio_inited = false; + +#ifdef ALLEGRO_CFG_IIO_HAVE_GDIPLUS + _al_shutdown_gdiplus(); +#endif }
|
Aikei_c
Member #14,871
January 2013
|
I'll probably have to compile allegro myself for that, right? or I could just place shutdown_gdi myself in my code? |
Trent Gamblin
Member #261
April 2000
|
You can try calling _al_shutdown_gdiplus() yourself (you may have to declare it.)
|
Audric
Member #907
January 2001
|
Aikei_c said: It seems it's nothing serious I should care about. This could be the tip of the iceberg in a allegro bug, so thank you for your persistence. |
|