Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Segmentation Fault When Calling Draw Function


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 fireshadow4126   Members   -  Reputation: 113

Like
0Likes
Like

Posted 29 June 2012 - 07:05 AM

Hello,

I'm working on my game framework. It compiles fine, but when I run the executable (which is eventually going to be a working game), I get this message from gdb:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b73152 in Survive::Game::TwoD::Entity2D::draw (this=0x91a, display=0x640f20) at libsurvive/src/game/2d/Entity2D.cpp:26
26		  spr.draw(display, x, y);

This is the definition of Entity2D::draw:

void Entity2D::draw(SDL_Surface *display) {
	 spr.draw(display, x, y);
}

display is a pointer to the screen, I know it is valid.
spr is the entity's underlying sprite. I know it has been constructed correctly, because the entity initialized fine.
x and y are the coordinates to draw the sprite at. They have both been instantiated.

What might be causing this then?

I'm working in Ubuntu, using makefiles generated by premake to build.

Thanks in advance!
"Welcome to the desert of the real." -- Morpheus, The Matrix.

Sponsor:

#2 Tribad   Members   -  Reputation: 872

Like
1Likes
Like

Posted 29 June 2012 - 07:24 AM

This looks strange.
The this-pointer is an implicit parameter that you cannot see normaly. The this-pointer seems to be wrong. So you have no Entity2D object where you can call the draw method on.
This would think that something long before the crash goes wrong.

#3 RulerOfNothing   Members   -  Reputation: 1161

Like
0Likes
Like

Posted 29 June 2012 - 08:37 AM

Where is Entity2D::draw called from?

#4 mhagain   Crossbones+   -  Reputation: 8129

Like
0Likes
Like

Posted 29 June 2012 - 09:49 AM

This looks strange.
The this-pointer is an implicit parameter that you cannot see normaly. The this-pointer seems to be wrong. So you have no Entity2D object where you can call the draw method on.
This would think that something long before the crash goes wrong.

I agree with this. 0x91a is an unusual value for a pointer and suggests that something earlier in your program is scribbling over memory that it shouldn't.

I'm not familiar with gdb (or the Linux toolchain in general) so I don't know it's capabilities for helping you find that "something", but Valgrind or similar - if gdb proves unhelpful here - should be able to.

Edited by mhagain, 29 June 2012 - 09:49 AM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#5 fireshadow4126   Members   -  Reputation: 113

Like
0Likes
Like

Posted 30 June 2012 - 03:01 PM

Never mind, I was able to solve it.

It turns out that my implementation of a linked list was messed up, so there were some bad pointers in there.

On to fixing the next problem!
"Welcome to the desert of the real." -- Morpheus, The Matrix.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS