Search code examples
memorymallocsolarisld-preload

How to use watchmalloc for background processes


I am using Solaris x86 box. My application crashes with following stack trace.

fed155f9 realfree (816d878) + 97 fed151be _malloc_unlocked (7e0, 8047eac, 8047e3c, feffb7d8, 8047bac, 809dd6a) + 18c fed15008 malloc (7e0) + 34

I need to debug it with "watchmalloc". My application will be started by system inetd process. I cannot control its execution. Please let me know how to use watchmalloc in this scenario.

I set the following environment variable it helps only for process started from the shell.

LD_PRELOAD=watchmalloc.so.1 MALLOC_DEBUG=WATCH,RW

Solution

  • What about renaming your app to lets say myapp.bin, and install a small shell script like:

    ! /bin/sh

    LD_PRELOAD=watchmalloc.so.1 MALLCO_DEBUG=WATCH,RW export LD_PRELOAD MALLOC_DEBUG exec myapp.bin "$@"