public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ SEGMENT fault and vtable issues
@ 2012-10-14 21:20 Arthur Schwarz
  2012-10-15 10:15 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Arthur Schwarz @ 2012-10-14 21:20 UTC (permalink / raw)
  To: gcc-help

Product Version = NetBeans IDE 7.2 (Build 201207171143)
Operating System = Windows 7 version 6.1 running on x86
Java; VM; Vendor = 1.7.0_03
Runtime = Java HotSpot(TM) Client VM 22.1-b02

Cygwin gcc 4.5.3
             gdb 4.5.3

I have a problem with my C++ application. I have tried to find what is wrong in 
my code and am unsuccessful, and amm hping that you can identify the issue.

The code fails (for different reasons) in two locations:
[code]
  SlipHeader* oldHeader;
   delete oldHeader;     // SEGMENT fault; custom defined delete

  SlipHeader* header;
  stringstream pretty;
  pretty << header->toString(); // call to pure virtual function
[/code]

The sequence of events is:
1:  The first time through the code there is no exception.
2:  The second time through the code there is an exception

In the first case, the address pointed to by oldHeader is within the range of 
values which should not produce a segment fault. I do my own 
allocation/dallocation. During allocation I get a block of memory. The address 
pointed to is within the block. gdb doesn't provide any support in debugging so 
I can't get any support other than the assumption that at the time the delete is 
executed oldHeader points to or is the cause of the fault.

In the second instance I've looked at the vtable address and it is the same for 
both the failed instance and the successfully executing instance.

I've looked at my code (step by naughty step) to try to find when the transition 
from legitimate to illegitimate occurs and can not find any difference (to 
warrant the errors).

So, does anyone have any thoughts as to what I might have done wrong and how to 
find what I have done wrong? I've wored around the problem but I just know it's 
going to pop up elsewhere - I'm writing regression tests and these errors just 
popped up.

thanks
art

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-16 22:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-14 21:20 C++ SEGMENT fault and vtable issues Arthur Schwarz
2012-10-15 10:15 ` Jonathan Wakely
2012-10-17  5:58   ` Arthur Schwarz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).