--- title: Find leaks and heap corruption with libumem, gcore and mdb area: debug impact: MEDIUM tags: [libumem, umem_debug, mdb, gcore, findleaks, memory-leak, heap-corruption] verified: 2026-11-04 --- # Find leaks and heap corruption with libumem, gcore and mdb Preload libumem with `UMEM_DEBUG=default`, take a core of the running process with `gcore`, and read it with `mdb`. Without the `audit` option that `default` includes, no stacks are recorded and `UMEM_LOGGING=transaction` logs nothing. **Antipattern** ```sh # do not run these LD_PRELOAD=libumem.so.1 UMEM_LOGGING=transaction ./prog # no UMEM_DEBUG: no audit, nothing in the log pfexec crle -e LD_PRELOAD=libumem_malloc.so.1 # system-wide preload: Solnix deliberately avoids it gdb ./prog core # gdb without Solnix's core-note patch aborts on illumos cores (regcache.c); prefer mdb ``` **The Solnix way** ```sh # default = audit,contents,guards: audit keeps a 15-frame stack per buffer; guards fill and redzone buffers # verbose: also print each error to stderr; transaction log size defaults to 64k (K/M/G/T suffixes) LD_PRELOAD=libumem.so.1 UMEM_DEBUG=default,verbose UMEM_LOGGING=transaction=1M ./prog & pid=$! # let it run until it has leaked gcore -o /var/tmp/core "$pid" # writes /var/tmp/core. mdb /var/tmp/core.$pid > ::dmods -l # the dcmds the loaded dmods provide; confirm before you rely on one > ::findleaks # leak report (the MDB guide documents it for kmem; see Unverified) # libumem found corruption: it calls abort(3C); open that crash core instead pfexec mdb /var/cores/core.prog..