Question

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
Was it helpful?

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 "$@"

OTHER TIPS

Just replace your application by a wrapper that sets the required variables then launch the real application.

eg:

cd <path to myapp>
mv myapp myapp.real
cat > myapp <<%
#!/bin/ksh
export LD_PRELOAD=watchmalloc.so.1
export MALLOC_DEBUG=RW
exec $(dirname $0)/myapp.real "$@"
%
chmod +x myapp
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top