This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Precord RFA/RFC] Check Linux sys_brk release memory in process record and replay.
- From: Hui Zhu <teawater at gmail dot com>
- To: Michael Snyder <msnyder at vmware dot com>
- Cc: Eli Zaretskii <eliz at gnu dot org>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Sun, 14 Jun 2009 17:26:00 +0800
- Subject: Re: [Precord RFA/RFC] Check Linux sys_brk release memory in process record and replay.
- References: <daef60380905050607yc499e39n34ac56108225f6ec@mail.gmail.com> <daef60380905051913q7579eed8pe8b514e72145859c@mail.gmail.com> <833abiexcc.fsf@gnu.org> <daef60380905052035v2758da1ak27fabfd902dff32d@mail.gmail.com> <83tz3ycchv.fsf@gnu.org> <daef60380905061921k7ced158eu2a74bab604a700e1@mail.gmail.com> <83k54td2el.fsf@gnu.org> <daef60380905110006gaa1ac38r870f6be455a402fc@mail.gmail.com> <daef60380906081917k3eabe59an2ba2a2983c139d10@mail.gmail.com> <4A342EBB.4020601@vmware.com>
On Sun, Jun 14, 2009 at 06:56, Michael Snyder<msnyder@vmware.com> wrote:
> Hui Zhu wrote:
>>
>> Ping.
>
> OK, my bad for taking so long to get to this... please allow me
> to summarize the problem, to check my own understanding
> (tell me if I'm wrong).
>
For that "nice people" words. I just want to make a joke. :)
> Currently linux-record.c does not know how to "undo" a sys_brk
> system call. ?You (teawater) are concerned because if the child
> process calls sys_brk to free some memory, we cannot un-free it
> and therefore we may get into trouble by writing to the freed
> memory during replay. ?Something like this:
>
> ?1) child allocates memory X
> ?2) child writes to memory X
> ?3) child frees memory X
> ?4) user asks for reverse-continue
> ?5) gdb tries to revert the write that happened in step #2,
> ? ? gets SIGSEGV because location has been freed.
>
> So far so good?
>
> Now, your proposal is that during the record mode, we will
> detect any sys_brk call that frees memory, and query the
> user whether to continue or give up.
>
> I'm not too crazy about that solution. ?I think it's
> awkward, and drastic for a situation that may only be
> a problem later on (or not at all). ?Let me throw out
> some other ideas:
>
> A) Is it possible to actually "reverse" a sys_brk call?
> Suppose we record the arguments, and when we want to reverse
> it, we just change an increase into a decrease and vice versa?
>
> B) Suppose we wait until an actual memory error occurs
> during replay, and THEN inform the user? ?It will avoid
> warning him about something that may never happen.
>
> We could use catch_errors to trap the SIGSEGV, and then
> check to see if the error was caused by a write to memory
> above the BRK boundary. ?You will still need to keep track
> of the BRK boundary, but you won't have that awkward early
> query to deal with.
The sys_brk just can increase and decrease data segment size. The
decrease behavior is very hard to replay.
I read some code of malloc and free in glibc. I found that most of
time, free will not call brk to release memory to system. Because it
is low efficiency.
So I think when brk release really happen, give user a query is a easy
way to handle it.
What do you think about it?
thanks,
Hui