Skip to content
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

mallocwatch breaks on a c++ program #59

Closed
sudhackar opened this issue Mar 27, 2019 · 0 comments · Fixed by #60
Closed

mallocwatch breaks on a c++ program #59

sudhackar opened this issue Mar 27, 2019 · 0 comments · Fixed by #60

Comments

@sudhackar
Copy link
Contributor

If malloc is called in libstdc++ while loading before preeny_mallocwatch_orig has been called from call_init.part it crashes as such

Program received signal SIGSEGV (fault address 0x0)
pwndbg> bt
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff77d0ea6 in malloc (size=72704) at /tmp/preeny/src/mallocwatch.c:30
#2  0x00007ffff72d59c0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff7de879a in call_init (l=<optimized out>, argc=argc@entry=1, argv=argv@entry=0x7fffffffdff8, env=env@entry=0x7fffffffe008) at dl-init.c:72
#4  0x00007ffff7de88ab in call_init (env=0x7fffffffe008, argv=0x7fffffffdff8, argc=1, l=<optimized out>) at dl-init.c:30
#5  _dl_init (main_map=0x7ffff7ffe170, argc=1, argv=0x7fffffffdff8, env=0x7fffffffe008) at dl-init.c:120
#6  0x00007ffff7dd9c5a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#7  0x0000000000000001 in ?? ()
#8  0x00007fffffffe33d in ?? ()
#9  0x0000000000000000 in ?? ()

Fix should be pretty simple, checking if original_mallocand family is actually set or not and then calling preeny_mallocwatch_orig

void *r = original_malloc(size);

I'll send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant