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

Abseil is conflict with tcmalloc #42

Closed
tjb1216 opened this issue Nov 13, 2017 · 8 comments
Closed

Abseil is conflict with tcmalloc #42

tjb1216 opened this issue Nov 13, 2017 · 8 comments
Assignees

Comments

@tjb1216
Copy link

tjb1216 commented Nov 13, 2017

If I link abseil and tcmalloc together in my program, It will shutdown and say "Check failed: MallocHook::RemoveNewHook(&InitialNewHook):". But if I use abseil only or tcmalloc only, It will run OK, so I think abseil is conflicted with tcmalloc.

@tjb1216
Copy link
Author

tjb1216 commented Nov 13, 2017

I put absl after tcmalloc, and it works, I don't know if there are any hiddlen problem.

@ahedberg
Copy link
Contributor

Didn't have a chance to take a look at this today, but I'll investigate tomorrow. Thanks for your patience!

@ahedberg
Copy link
Contributor

@tjb1216 - are you using Bazel to build your project? gperftools doesn't provide a Bazel BUILD file, so if you have one that works, I'd like to borrow it rather than spend time reinventing the wheel.

@derekmauro
Copy link
Member

@ahedberg - You shouldn't need a BUILD file to reproduce this. You can compile gperftools separately and then link against it. Ping me if you need more details.

@ahedberg
Copy link
Contributor

Thanks @derekmauro - finally figured out where my built-from-source libtcmalloc.so was hiding.

Current theory (assuming use of LD_PRELOAD to use tcmalloc instead of the system malloc):

  • Calls to MallocHook::InitialNewHook are using the Abseil implementation.
  • The failing call to MallocHook::RemoveNewHook(&InitialNewHook) is using the tcmalloc/gperftools implementation.
  • This means means that there are two HookList<MallocHook::NewHook> objects in any program - one for Abseil (where things get added), and one for tcmalloc.
  • So there's nothing to remove from the tcmalloc HookList in RemoveNewHook, which causes the check failure (because HookList<MallocHook::NewHook>::Remove returns false).

We think this might have something to do with both Abseil and tcmalloc overriding mmap, but I need to investigate further.

@ahedberg
Copy link
Contributor

@derekmauro and I figured out that the extern "C" parts of MallocHook and MallocExtension are in conflict between tcmalloc and absl, as they have the same names. I'm working on a fix.

@ahedberg
Copy link
Contributor

Apologies for the silence here. We're still discussing how best to fix this internally. Rest assured we haven't forgotten about this.

@ahedberg
Copy link
Contributor

This has been fixed. Please let us know if you're experiencing additional issues using tcmalloc with Abseil.

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

No branches or pull requests

3 participants