[Bug 264444] dtrace ustack() cannot decode stack frames in shared libraries opened with dlopen after the program terminates

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 04 Jun 2022 03:24:53 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264444

            Bug ID: 264444
           Summary: dtrace ustack() cannot decode stack frames in shared
                    libraries opened with dlopen after the program
                    terminates
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: asomers@FreeBSD.org

dtrace's ustack() function is supposed to unwind a user stack trace.  It
usually can.  But it seems that it cannot decode stack frames from a shared
library, if that shared library was loaded with dlopen and the program exits
before dtrace does.

Steps to Reproduce (admittedly, with difficulty)
1) pkg install rust c-blosc isa-l llvm pkgconf git
2) pkg install fio-3.30    # May not build with other fio versions
3) git clone https://github.com/bfffs/bfffs.git
4) cd bfffs
5) git checkout 6e2c7b16b681d54d239b0f7518e612d5df36d096
6) cargo build -p bfffs-fio
7) truncate -s 1g /tmp/bfffs.img
8) cargo run --bin bfffs -- pool create testpool /tmp/bfffs.img
9) sudo dtrace -x ustackframes=100 -n 'profile-199 /pid == $target && arg1/
{@[ustack()] = count();}' -o fio.stacks -c "fio bfffs-fio/data/ci.fio"
10) Examine fio.stacks.  It will contain frames from fio and libc.so, but none
from libbfffs.so.  Where there should be some, it will instead contain hex
numbers, like this:

              libc.so.7`memcpy+0xb0
              0xfcdfdc73c
              fio`io_u_queued_complete+0x7a
              fio`wait_for_completions+0x7b
              fio`do_io+0x678
              fio`thread_main+0xbe0
              libthr.so.3`0x822130a7a

-- 
You are receiving this mail because:
You are the assignee for the bug.