This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: 96 bit pointer reset only the least 64 bits
- From: Andrew Haley <aph at redhat dot com>
- To: Nir Piterman <nir dot piterman at doc dot ic dot ac dot uk>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 31 Oct 2008 09:36:19 +0000
- Subject: Re: 96 bit pointer reset only the least 64 bits
- References: <490A0213.9000507@doc.ic.ac.uk>
Nir Piterman wrote:
> I have a strange problem with setting pointers to 0. It happens in a 64
> bit environment.
>
> I am using a big package (which I know very little about) and get it to
> crash.
> I can narrow the problem to some function that handles a pointer and on
> returning from the function the pointer is changed (I completely don't
> understand how is it possible that returning from a function can change
> the pointer unless there is some memory leak).
>
> The thing is, when I print the pointer using printf instead of getting 8
> chars I get 12 chars.
> The change that is done to the pointer is that the least 64 bits are set
> to 0 and the top 32 bits remain unchanged (which could make some sense
> if this memory was deallocated by some side effect that I don't see).
> Furthermore, when I compare this pointer to 0 I get that it is not 0
> (and in my opinion this is what causes the program to crash).
>
> Does this ring a bell to anyone?
Your'e almost certainly looking at memory corruption. Valgrind's memory
checker would be a good start. Also, gdb supports watchpoints, so you
can see when the pointer is changed.
Andrew.