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

elfmalloc: Detect or eliminate frees from other allocators #110

Open
joshlf opened this issue Oct 17, 2017 · 3 comments
Open

elfmalloc: Detect or eliminate frees from other allocators #110

joshlf opened this issue Oct 17, 2017 · 3 comments

Comments

@joshlf
Copy link
Collaborator

joshlf commented Oct 17, 2017

When dynamically loading on Mac, the loader seems to free a pointer to us that was not allocated by us (presumably it was allocated by malloc before our symbols were loaded). As I see it, we have two options:

  • Figure out how to load on Mac so that this doesn't happen
  • Figure out how to detect whether a pointer is ours; if it isn't, just leak it (or maybe free it to libc free?)

@davidtgoldblatt Have you folks run into this problem with jemalloc?

@davidtgoldblatt
Copy link

I don't remember all the details, but related is the OS X "malloc zone" API (jemalloc stuff is in src/zone.c).

I think Firefox may need to deal with this as well -- I remember that they have some wonkiness in dealing with the mixture of allocators.

@davidtgoldblatt
Copy link

My memory is that this is fundamental on OS X; there will be a mixture of pointers allocated by your malloc and the libc malloc no matter what, so that if you want to replace libc malloc you need to be able to handle this issue. I'm less confident about that one though.

@joshlf
Copy link
Collaborator Author

joshlf commented Oct 17, 2017

Ah that's very helpful, thanks! I'll take a look at the malloc zone API and see what we can do about it.

EDIT: Useful links for posterity:

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

No branches or pull requests

2 participants