|
-
September 25th, 2011, 12:17 AM
#8
Re: Segmentation Fault ??
 Originally Posted by JacobNax
the application fails at some point when i compile it in gcc (linux) but works just fine with the VC compiler
That's quite interesting. If anything I'd expect it to be the other way around. I use VC++ as well as gcc and one thing I've noticed about VC++ is that it will almost never allow you to access memory you've deleted. This is especially true for Debug builds. gcc unfortunately is a different kettle of fish. In my experience, it seems perfectly happy to let you to carry on using deleted pointers until the memory gets re-used for something else - at which point you get a sudden and apparently inexplicable crash.
As Paul described, corrupted pointers give you exactly this kind of problem. Your app works perfectly most of the time but crashes at random for no obvious reason. Or the app works fine on your machine but not on somebody else's.
If you're confident that this isn't a synchronisation issue, the other most likely cause is that Clients.m_socket is getting overwritten by garbage. Is there a buffer in front of it that's too small? Maybe the buffer is 10 bytes but somewhere, you're writing 11 bytes of data into it. Because of structure packing, this is the kind of problem that might show up in one compiler but not the other.
Try building the gcc version with the --mms-bitfields flag. This forces your gcc app to use the same structure packing as VC++. It's not a fix but if that causes the problem to go away, it might indicate a data member getting overwritten somehow.
Of course if you had access to a decent debugger you could track this problem down in a few minutes. Sadly, you're stuck with gdb.
"A problem well stated is a problem half solved.” - Charles F. Kettering
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|