This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to use the malloc hooks in a thread-safe manner


Hi All,


The code example of the malloc hooks (http://www.gnu.org/s/libc/manual/html_node/Hooks-for-Malloc.html) removes the hooks and reinstalls them a bit later to prevent infinite recursion when performing.

How do I adapt this code to work in a multithreaded application? Temporarily removing the hooks will cause calls to malloc (and free, etc) from other threads to completely bypass the hooks. Any synchronization primitives in the hook functions will not work, because when the hooks are unhooked the other threads don't pass through the synchronization.


Regards,

Fabian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]