Re: writing to freed memory--issues
- From: "bill pursell" <bill.pursell@xxxxxxxxx>
- Date: 28 Mar 2006 09:33:23 -0800
Kasper Dupont wrote:
bill pursell wrote:
I was playing around with a toy program, which led to some confusion.
I had expected that doing the following would lead to an immediate
segfault:
free(a);
*a=0;
However, it did not.
The result is undefined, which means it could do anything that
process is allowed to do. If you want to catch such a bug look
on some of the debugging tools that were written for the purpose:
Sure, the result is undefined, but the behavior is very
consistent. I'm not concerned about catching the
bug, just trying to understand the behavior.
I concluded that when I had allocated
enough space that the process required an extra page, the page was
given, and then taken back on the free, so that writes to the freed
page caused the error.
Then I'd say you jump to conclusions. There are other possible
explanations for what you are seeing.
Maybe "concluded" is the wrong word. "hypothesized" would
be more accurate.
<snip>
1) what is special about 33790? Why does the segfault keep occurring
at that point?
Does there have to be anything special about it?
No, but there seems to be. I'm hoping that understanding
what's happening here will give me some insight into memory
management. Trying to understand the OS, I figure understanding
the extreme cases will help. I'll peek around in
/proc/self/maps and see if I can correlate anything to the point
at which the error occurs. It may be completely pointless, but
it's guaranteed to be at least a little bit fun. (Which is to say
that I'll probably stop as soon as I get bored!)
.
- References:
- writing to freed memory--issues
- From: bill pursell
- writing to freed memory--issues
- Prev by Date: Re: what's the relation among wxWidgets,xWindows and GTK+?
- Next by Date: Re: Shared libraries : better management strategies ?
- Previous by thread: Re: writing to freed memory--issues
- Next by thread: Re: writing to freed memory--issues
- Index(es):
Relevant Pages
|