Jump to content
SubSpace Forum Network

Recommended Posts

Posted

Well yeah, two days of straight debugging and I finally found this one. I think it surp!@#$%^&*es my previous favorite en!@#$%^&*led "pragma pack is the devil": http://forums.minegoboom.com/viewtopic.php?t=6508

 

anyways I was using an STL vector to store the ships which should be drawn on the screen. I then passed around pointers to these Ships to other modules so they could modify them as they see fit. The problem is, a vector reallocates memory as it grows... so when I had the pointer to the first element and then inserted another ship, the pointer to the first ship no longer pointed to valid memory. Rather than crashing, the program continued to run, until something else allocated some memory in the same spot (which happened to be an image that I wanted to draw), and then whenever I modified the ship I was also modifying the image. SDL then complained that images should be unlocked when drawing them to the screen (apparently the ships's y pixel location mapped to the locked field of the SDL_Surface structure)... so basically I had to work backwards from SDL's complaints to find the real problem.

 

anyways yeah just rambling... that's about 20 hours of my life I'll never get back!

Posted
ooh that's one nasty bug. I hate these bugs that seem random but are caused by some stupid stupid thing that's hidden like !@#$%^&* and involves LOTS of frustration and backtracking to find ....

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...