Giter VIP home page Giter VIP logo

Comments (2)

bassam avatar bassam commented on May 22, 2024

it looks like this is much harder to get working with static linking. While jemalloc and tcmalloc seem to support static linking, any program that calls fork (like ceph) seems to pull in libc specific functions (like __malloc_fork_lock_parent) and result libc's allocators being pulled in during linking. Here's a simple repro:

#include <stdlib.h>
#include <unistd.h>

int main() {
  void *i = malloc(0);
  fork();
  return 0;
}
 g++ test.c -o test -static -ltcmalloc_minimal -lpthread -Wl,-Map,test.map
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libc.a(malloc.o): In function `__libc_malloc':
(.text+0x6170): multiple definition of `__libc_malloc'
/usr/lib/gcc/x86_64-linux-gnu/6/../../../../lib/libtcmalloc_minimal.a(libtcmalloc_minimal_la-tcmalloc.o):(google_malloc+0x0): first defined here
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libc.a(malloc.o): In function `__libc_malloc':
(.text+0x6170): multiple definition of `malloc'

and if you look at test.map produced by the linker:

/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libc.a(malloc.o)
                              /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libc.a(fork.o) (__malloc_fork_lock_parent)

from rook.

bassam avatar bassam commented on May 22, 2024

this is a problem with tcmalloc as well gperftools/gperftools#856

from rook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.