Program Crashing PT2

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Dec 2006
Posts: 22
Reputation: jd_1604 is an unknown quantity at this point 
Solved Threads: 0
jd_1604 jd_1604 is offline Offline
Newbie Poster

Program Crashing PT2

 
0
  #1
Jan 26th, 2007
O.K. Ive compiled my program for debugging. I really don't know where to start looking. My program consists of two blocks of source code (Robotmoves.cpp and Character.cpp) and one header file (Character.h) Once I have compiled and attempted to run the program the error tells me my Robotmoves.EXE had triggered a breakpoint. This brakpoint is found in draw.inl (which I presume is part of the allegro library)
The point is triggered on line 250
  1. AL_INLINE(void, draw_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y),
  2. {
  3. ASSERT(bmp);
  4. ASSERT(sprite);
  5.  
  6. if (sprite->vtable->color_depth == 32) {
  7. bmp->vtable->draw_256_sprite(bmp, sprite, x, y);
  8. }
  9. else {
  10. ASSERT(bmp->vtable->color_depth == sprite->vtable->color_depth);
  11. bmp->vtable->draw_sprite(bmp, sprite, x, y);
  12. }
  13. }) //**Breakpoint Line 250 is here**
  14.  
  15.  
  16. AL_INLINE(void, draw_sprite_v_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y),{
  17. ASSERT(bmp);
  18. ASSERT(sprite);
  19. ASSERT(bmp->vtable->color_depth == sprite->vtable->color_depth);
  20.  
  21. bmp->vtable->draw_sprite_v_flip(bmp, sprite, x, y);
  22. })
I really don't know, unless I posted my entire code, where else I should be looking. I also tried compiling with Dev C++ but got the same thing. Animation frame comes up, arrow key is pressed, 'Allegro had encountered a problem and needs to close. We are sorry......'
What can I do now?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,661
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1500
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Program Crashing PT2

 
0
  #2
Jan 26th, 2007
put a break point at the beginning of the function and step through the program one line at a time to see where it breaks. Also check the validity of all pointers -- If a pointer has a value something like "hchchchchc" that is what the compiler initializes them to when compiled for debug -- and is an uninitialized or bad pointer.

And please stop creating a new thread every time you have a new question about the same program. Just post your question(s) to the existing thread, that will bump it to the top of the list.
Last edited by Ancient Dragon; Jan 26th, 2007 at 11:40 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 22
Reputation: jd_1604 is an unknown quantity at this point 
Solved Threads: 0
jd_1604 jd_1604 is offline Offline
Newbie Poster

Re: Program Crashing PT2

 
0
  #3
Jan 27th, 2007
Originally Posted by Ancient Dragon View Post
put a break point at the beginning of the function and step through the program one line at a time to see where it breaks. Also check the validity of all pointers -- If a pointer has a value something like "hchchchchc" that is what the compiler initializes them to when compiled for debug -- and is an uninitialized or bad pointer.

And please stop creating a new thread every time you have a new question about the same program. Just post your question(s) to the existing thread, that will bump it to the top of the list.
Sorry But I must be really thick in the head today. I'm having trouble understanding by what you mean when you say to create a breakpoint at the start of the function. All my pointers seem to be correct. Forgive my ignorance
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Program Crashing PT2

 
0
  #4
Jan 27th, 2007
He means creating a breakpoint in the debugger - you do have one don't you? They help immensly in tracking down bugs and memory leaks.

If you don't have a debugger, I recommend you liberally sprinkle print statements so you can see the values of not only what the pointers contain, but also the memory addresses of them before the program crashes.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Program Crashing PT2

 
1
  #5
Jan 27th, 2007
From your other post
> Assert failed at line 250 of c:\code\allegro\include\allegro\inline/draw.inl
Open draw.inl in your editor.
Goto line 250.
Read the line which will be something like say ASSERT(x >= 0);

The code expects that expression to be true.
In your program, that expression was false.

Now ask yourself how the condition comes to be false, and how can I make it be true.
Perhaps by initialising variables, or allocating resourses, or ....
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 1254 | Replies: 4
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC