Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » get 0xC0000005 on al_destroy_display()

This thread is locked; no one can reply to it. rss feed Print
get 0xC0000005 on al_destroy_display()
megasonimon
Member #14,613
October 2012

Hi
I'm trying to run a sample code on Allegro wiki
http://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial/Displays

but it crashes at al_destroy_display(display) and said
Process returned -1073741819 (0xC0000005)

Call stack:
#0 00000000 0x00401b35 in al_destroy_display() (??:??)
#1 00000000 0x00000000 in ??() (??:??)

I'm using Windows 7 pro x64, Code::Blocks with TDM-GCC 4.6.1
Allegro 5.0.7
I'm sure I installed Allegro correctly because with the same setting
I can compile and run the code without any error on my other laptop

What could be a possible reason that causes the problem? Thanks.

Gabriel Campos
Member #12,034
June 2010
avatar

Show us some code, maybe u forgot something in the code that is crashing...

torhu
Member #2,727
September 2002
avatar

Are you sure that the display argument is valid? 0xC0000005 is Access Violation, which usually means a null pointer or otherwise invalid pointer is involved. Make sure you don't call al_destroy_display twice, although it's possible that that is fine.

And post your code...

megasonimon
Member #14,613
October 2012

well, I just copy and paste that sample code and didn't change anything

#SelectExpand
1#include <stdio.h> 2#include <allegro5/allegro.h> 3 4int main(int argc, char **argv){ 5 6 ALLEGRO_DISPLAY *display = NULL; 7 8 if(!al_init()) { 9 fprintf(stderr, "failed to initialize allegro!\n"); 10 return -1; 11 } 12 13 display = al_create_display(640, 480); 14 if(!display) { 15 fprintf(stderr, "failed to create display!\n"); 16 return -1; 17 } 18 19 al_clear_to_color(al_map_rgb(0,0,0)); 20 21 al_flip_display(); 22 23 al_rest(10.0); 24 25 al_destroy_display(display); 26 27 return 0; 28}

During the tests I modified al_rest(10.0); to al_rest(1.0); to make the program go to the end faster

torhu
Member #2,727
September 2002
avatar

Replace "attach" with "code" i those tags, and [] with <>.

Does it actually display a window before it crashes?

megasonimon
Member #14,613
October 2012

Yes, it displays a window
and I just found out that it shows blue instead of black (al_map_rgb(0,0,0))

torhu
Member #2,727
September 2002
avatar

I don't really have any good ideas here. Is that code actually copied from your editor, not from the example page?

EDIT: You could attach the allegro.log file, if there is one. Maybe there is a clue in that.

Cassio Renan
Member #14,189
April 2012
avatar

I got the exact same problems a few months ago, with a machine of roughly the same specs as yours(W7-pro x64, DX11), and couldn't really get it to work. I'm guessing compatibility issues, but I'm no pro.

I could only solve my problem by compiling allegro from source.

At the time, I posted a thread here. It has an allegro.log file, if it's any help. When I compiled from source I asked to close the topic, so there isn't really any more feedback there. Sorry about that.

here's the thread.
http://www.allegro.cc/forums/thread/610583

good luck!

Kris Asick
Member #1,424
July 2001

megasonimon, what kind of video card/chipset do you have and are your video drivers up to date? Because you're not explicitly setting the ALLEGRO_FULLSCREEN or ALLEGRO_WINDOWED flags with al_set_new_display_flags() before calling al_create_display(), it's possible your combination of video card/chipset and driver are causing problems with Allegro's default fullscreen/windowed setting. (Which truthfully, I don't know what the default is.)

--- Kris Asick (Gemini)
--- http://www.pixelships.com

megasonimon
Member #14,613
October 2012

adding al_set_new_display_flags(ALLEGRO_WINDOWED ); before al_create_display doesn't change anything

Video Card:
NVIDIA GeForce GTX560 SE driver version 9.18.13.623 (2012/8/20)

and where is allegro.log located?

Neil Walker
Member #210
April 2000
avatar

does it fail if you remove the clear and flip?

have you tried suggesting ALLEGRO_OPENGL

have you recently updated your video drives? if not, do it.

have you tried changing resolution to use the desktop (al_get_display_height(), etc)

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

megasonimon
Member #14,613
October 2012

>Neil Walker
I'll try your suggestion after school today
and I just update video card driver about 3 days ago

another strange thing
with the same code, I can compile and run without error on my laptop
and I copied the binary(.exe) to my PC and it still works

but I compile the same code on my PC, run it on my PC causes 0xC0000005 error
and I copied the binary on PC to my laptop, it crashed with the same error

so there might be some problem during compile or link on my PC?

>Cassio Renan
Thanks for your suggestion, I will try to compile allegro source code

Kris Asick
Member #1,424
July 2001

Are you using the same compiler and project files on both systems? If so, then there might be something wrong with your compiler/linker on the one system and you should reinstall it all completely.

Also, AFAIK, Allegro is designed specifically for making 32-bit apps. Your compiler may be attempting to make a 64-bit app, in which case Allegro would be unable to load properly. You may wanna check into that too and ensure you're compiling a 32-bit app.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

torhu
Member #2,727
September 2002
avatar

and where is allegro.log located?

In the same directory as your executable. Or maybe the current working directory, if that's not the same.

I think only the debug build of Allegro creates it though.

megasonimon
Member #14,613
October 2012

>Kris Asick
Both my laptop and my PC are running Win7 pro x64
same compile, IDE, environment setting
that's why I'm confused

[Edit] I switch to dynamic link and got log file
(it didn't appear at all when I use static link...)

[Edit2] 10.12
I tried Visual Studio Express 2010 and worked fine
so this is some compatibility issue with gcc 4.6.1 tdm version of allegro 5.0.7

Go to: