-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The pintool is broken. #3
Comments
As an example, the following program produces wrong output: #include <stdlib.h>
int main(int argc, char **argv)
{
(void) argc, (void) argv;
void *a;
int i;
for (i = 0; i < 10; ++i)
{
a = malloc(i * 1000);
if (i % 2)
free(a);
}
return 0;
} Produces this trace on my setup:
Villoc shows the final state as being: Which is obviously wrong as the program is perfectly valid and shouldn't produce overlapping blocks. @sam-b maybe you could look at this? |
Just made a pull request to address some of this - the overlapping blocks seem to be from the loader which does some funky memory allocation that wouldn't normally be valid, the version in the pull request avoids this by only instrumenting after main is called. I also fixed the minor formatting issue. It should definitely be possible to detect abnormal program termination as people are pin for fuzzing instrumentation, would need to have a look into this though. I'm not entirely sure if over coming the first issue is easily do-able. Obviously if you don't think pin is appropriate for this use case you can feel free to remove it from the repository. |
Thanks for the work and the investigation! I'll look into this soon. I don't have anything against pin :) I think it's something lots of people would want to try and it's a good thing an example is available in the repository. What I'm saying is that for simply monitoring calls to malloc & friends hooking the shared library using |
I confirm seeing this issue on my Gentoo into my own pin tool. Maybe one solution is to filter the IMGs we instrument and skeep instrumentation of "ld-linux-x86-64.so.2" : if (strncmp(IMG_Name(img).c_str(),"ld-linux",8) != 0)
{
instrImageMalloc(img,v);
instrImageNew(img,v);
instrImageRealloc(img,v);
instrImageCalloc(img,v);
} |
The pintool is broken. I shouldn't have merged it.
This isn't easy to get right because pintools isn't the right tool for the job. ltrace or LD_PRELOAD should be used to debug dynamic calls. If someone wants to fix this OK. Here are the issues:
The text was updated successfully, but these errors were encountered: