Remix.run Logo
Joker_vD 9 hours ago

    The use of these hook functions is not safe in multithreaded
    programs, and they are now deprecated.  From glibc 2.24 onwards,
    the __malloc_initialize_hook variable has been removed from the
    API, and from glibc 2.34 onwards, all the hook variables have been
    removed from the API.  Programmers should instead preempt calls to
    the relevant functions by defining and exporting malloc(), free(),
    realloc(), and calloc().
nly 8 hours ago | parent [-]

Yeah. Shame though because it gave you the option to control exactly when you hooked and didn't hook, which let stop and start debugging allocations based on arbitrary triggers.

The global variable approach was very useful and pretty low overhead.

fweimer 5 hours ago | parent | next [-]

You can still override malloc and call __libc_malloc if you do not want to bother with dlsym/RTLD_NEXT. These function aliases are undocumented, but for a quick experiment, that shouldn't matter.

jeffbee 6 hours ago | parent | prev [-]

If you only wanted to observe the behavior the post is discussing, it seems like `ltrace -e malloc` is a lot easier.