stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicole Willson" <will...@roguewave.com>
Subject RE: problem in temp_buffer
Date Thu, 27 Jul 2006 14:44:04 GMT
The problem is simply that the address for last is:
(gdb) print last
$5 = (Header *) 0x77f00008 
And the address for ptr (after malloc) is:
(gdb) print ptr
$4 = (void *) 0x77e00d30

Since ptr is 
(gdb) print block_size
$1 = 2147483680

The end of the block pointed to by ptr is 0xf7e00d50 - you will note
that last is inside of ptr's block of memory now.  Then when memset is
called on ptr setting everything to -1, last's information is
obliterated.

My question now is:
Since last is in the midst of the block allocated to ptr, shouldn't that
allocation have failed?

-----Original Message-----
From: Martin Sebor [mailto:sebor@roguewave.com] 
Sent: Tuesday, July 25, 2006 4:26 PM
To: stdcxx-dev@incubator.apache.org
Subject: Re: problem in temp_buffer

Nicole Willson wrote:
> On entering new.cpp last is:
> (gdb) print *last
> $1 = {prev_ = 0x77f81008, next_ = 0x0, ptr_ = 0x77f00020, size_ = 
> 524296,
>   id_ = 95, self_ = 0x77f00008}
> (gdb)
> 
> After 439         memset (ptr, -1, block_size); inside _new, last is:
> $12 = {prev_ = 0xffffffff, next_ = 0xffffffff, ptr_ = 0xffffffff, 
>   size_ = 4294967295, id_ = 4294967295, self_ = 0xffffffff}
> 
> Somehow the memset on ptr is messing with last.

I can't test it right now because the dang server is down again but it
seems that you should have all the info you need to find out what's
causing it. Step through the code line by line, printing out the values
of the variables, such as ptr and block_size. Given all the problems
this compiler has been having with exceptions I'd make sure that's not
part (or all) of the problem. I.e., if malloc(block_size) returns 0,
operator_new is supposed to throw an exception; the call to memset()
should never be reached.

Martin

Mime
View raw message