Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Exception thrown at 0x0F42F557

Credits go to Edgar Reynaldo for helping out!
This thread is locked; no one can reply to it. rss feed Print
Exception thrown at 0x0F42F557
frordX
Member #16,148
January 2016

Hi,
I have a problem when compiling a program with allegro. It drops me the next window.
https://gyazo.com/b3e29e827b4e65534889846e8fa508eb
Thanks for the help;

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

To clarify, your problem is not when you compile an Allegro program, but when you run it. The error image says you're accessing a NULL pointer. Either it is uninitialized, initialized to zero and never created with new or malloc, or you're destroying a resource and setting it back to zero and then trying to access it again.

To help more, we need to see code.

Chris Katko
Member #1,881
January 2002
avatar

One more additional note. If you never check return values this can happen as well. If Allegro isn't setup correctly, you won't get an image. If you try and load a file that doesn't exist or is corrupted, you won't get an image. If you try to create a new bitmap and it fails because of something like invalid width/height or running out of memory, it will fail.

All of those cases will return error codes that need to be checked otherwise your program can fail at any time. Always check for and deal with return codes. Some functions return NULL if they fail, some functions return -1 or another value. Read documentation to know when and where.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

frordX
Member #16,148
January 2016

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

It's much more helpful to us if you post your code in <code>code goes here</code> tags.

Also, you don't want to create and destroy a display on every frame of your logic processing. You want to do it once at the beginning and once at the end.

In addition, you never called al_init. Allegro functions won't work unless this call is successful. Try fixing those things and then report back.

Bruce Pascoe
Member #15,931
April 2015
avatar

For some reason I misread the title of this thread as Explosion thrown... :o

Mark Oates
Member #1,146
March 2001
avatar

{"name":"610061","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/5\/8539aae09846c0985ea9760e8946d00a.gif","w":500,"h":239,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/5\/8539aae09846c0985ea9760e8946d00a"}610061

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

frordX
Member #16,148
January 2016

It worked, thanks :D

Chris Katko
Member #1,881
January 2002
avatar

Bruce Pascoe: People might take them a little more seriously if end users saw "Explosion was Thrown" on their software!

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Rodolfo Lam
Member #16,045
August 2015

Just happened to notice... On the top of the page it says that credits go to Edgar for helping... Was that automatic or did Matthew manually modify this page to reflect that?

GullRaDriel
Member #3,861
September 2003
avatar

The OP can edit his post to give forgotten credit IIRC.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

When you submit or edit a post you get the chance to give credit to the people who replied if you set the thread type as 'A question or problem with a specific answer'. You only get to do it once though. Once you decide who to give credit to you can't change it.

Go to: