help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: g++ usage of new generates a segmentation fault


From: Alan Woodland
Subject: Re: g++ usage of new generates a segmentation fault
Date: Fri, 14 Jul 2006 10:16:43 +0100
User-agent: Debian Thunderbird 1.0.2 (X11/20060423)

Christophe Limbrée wrote:
> Paul Pluzhnikov a écrit :
>>You have a bug, and valgrind will likely show it to you immediately,
>>so why don't you stop wasting time hypothesisizing what the problem
>>might be, and use proper tools to find it.
> Valgrind said:
> 
> ==16807== LEAK SUMMARY:
> ==16807==    definitely lost: 0 bytes in 0 blocks.
> ==16807==      possibly lost: 0 bytes in 0 blocks.
> ==16807==    still reachable: 35182 bytes in 15 blocks.
> ==16807==         suppressed: 0 bytes in 0 blocks.
> Segmentation fault
> 
> Do I have to understand that there is no problem?
It's not leaking, but the segmentation fault is quite obviously a problem.

> And before
> 
> ==16807== Use of uninitialised value of size 4
This might suggest you've tried to use an unitialised pointer somewhere.
Assuming you're running on IA32 4 would be the right size.

> ==16807==    at 0x8049217: main (in /home/lch/SRC/TCOV/ECXX/ecxx)
> ==16807==
> ==16807== Process terminating with default action of signal 11
> (SIGSEGV)
> ==16807==  Bad permissions for mapped region at address 0x804A8BA
> ==16807==    at 0x8049217: main (in /home/lch/SRC/TCOV/ECXX/ecxx)
What you really want here is a stack trace. Did you compile with
debugging symbols? That would show you more precisely where the error
came from. BTW I'd be using gdb to find the root of this problem I think.

> ==16807==
> ==16807== ERROR SUMMARY: 41 errors from 19 contexts (suppressed: 0 from
> 0)
> ==16807== malloc/free: in use at exit: 35182 bytes in 15 blocks.
> ==16807== malloc/free: 60 allocs, 45 frees, 39789 bytes allocated.
> ==16807== For counts of detected errors, rerun with: -v
> ==16807== searching for pointers to 15 not-freed blocks.
> ==16807== checked 1276260 bytes.
> 
> And finally I have no idea where the fault can be. The fact is that if
> I use myclass instance(param, ...), I don't have the problem. If I use
> myclass *instance = new myclass(param, ...), I have the problem. Maybe
> because I link a .o that I have created.
Just because it works in one case doesn't mean your code is error free
;) Try to find exactly which line it is that's breaking.

Alan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]