FAQ Search
Memberlist Usergroups
Profile
  Forum Statistics Register
 Log in to check your private messages
Log in to check your private messages
Moonpod Homepage Starscape Information Mr. Robot Information Free Game Downloads Starscape Highscore Table
July-06: Xenomorph
Goto page Previous  1, 2
Post new topic   Reply to topic    Discussion Pod Forum Index -> Developer Diary View previous topic :: View next topic  
 Author
Message
Moonpod Developer Diary RSS feed -RSS Feed
Johnh



Joined: 06 Sep 2003
Posts: 160



PostPosted: Thu Jul 06, 2006 3:15 pm    Post subject: Reply with quote

Weeble wrote:
Speaking of baffling memory corruption bugs, I did this not so long ago, and was aghast when I discovered what I'd done:
Code:

struct GUID
{
    // ...
}
// ...
class cSomething
{
public:
    cSomething(const cGUID& guid, int x, int y)
        :m_guid(guid),m_x(x),m_y(y)
    {}
    DoSomething();
    // ...
private:
    // ...
    const GUID& m_guid;
    int m_x;
    int m_y;
}

Of course, all of this was spread across several files. The critical thing to spot is the ampersand on the line "const GUID& m_guid;". That wasn't supposed to be there. But there was nothing for the compiler to find wrong with it, and I didn't realise for a while that is was like that. So it looks to me like m_guid gets horribly corrupted some time after construction but before DoSomething() is called. In actuality I've got a reference to a piece of memory I don't own that's probably in a stack frame that went out of scope shortly after my cSomething was constructed.

Sorry, that can't have been terribly interesting for anybody else.


Took me awhile to figure out what exactly you were doing wrong too, and you pointed it right out to me.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Discussion Pod Forum Index -> Developer Diary All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group