[DynInst_API:] Malloc returns same address after detach and reattach


Date: Tue, 5 Aug 2014 15:00:17 -0400
From: Francis Deslauriers <francis.deslauriers@xxxxxxxxxxxx>
Subject: [DynInst_API:] Malloc returns same address after detach and reattach
Hi folks,

I ran into a problem while trying to instrument a program a second
time after detaching from it.

Here are the steps to witness the problem:
1. Attach to the running process
2. Allocate memory in the mutatee using process::malloc method
3. Detach and continue the process
4. Reattach to the same process
5. Same as 2
6. Same as 3

At memory space allocated at steps 2 and 4 are located at the same
memory address.

I made a small program that triggers this issue. In this program, I
allocate 4 bytes for a BPatch_variabExpr in the mutatee and pass the
address of the variable to a function call that prints this address.
When i run the program, I see that both malloc calls return the same 4
bytes.

Is there a way for the mutator to detect that the mutatee has already
been modified?

Also, if I instrument a function entry already instrumented(during a
previous attach) a second time only the last instrumentation remains.
In my sample program, I instrument function foo two times and only the
second call remains.

Thanks,

Francis Deslauriers

Attachment: multi-malloc.tar.gz
Description: GNU Zip compressed data

[← Prev in Thread] Current Thread [Next in Thread→]
  • [DynInst_API:] Malloc returns same address after detach and reattach, Francis Deslauriers <=