namhyung / uftrace

Function graph tracer for C/C++/Rust/Python
https://uftrace.github.io/slide/
GNU General Public License v2.0
3.01k stars 442 forks source link

unittest segaulting with musl #1299

Open cz172638 opened 3 years ago

cz172638 commented 3 years ago

while trying to package uftrace for alpine, got following segfault: running in podman:

$ podman run --cap-add CAP_SYS_PTRACE  -v $PWD:/uftrace -w /uftrace --rm -it alpine:3.14
/uftrace # apk add -q --no-progress --no-cache elfutils-dev python3-dev ncurses-dev pkgconf luajit-dev capstone-dev libexecinfo-dev linux-headers musl-dev bash make gcc g++ libexecinfo-dev python2 gdb musl-dbg
/uftrace # ./configure --prefix=/usr --ldflags="-lexecinfo"
uftrace detected system features:
...         prefix: /usr
...         libelf: [ on  ] - more flexible ELF data handling
...          libdw: [ on  ] - DWARF debug info support
...      libpython: [ on  ] - python scripting support
...      libluajit: [ on  ] - luajit scripting support
...    libncursesw: [ on  ] - TUI support
...   cxa_demangle: [ on  ] - full demangler support with libstdc++
...     perf_event: [ on  ] - perf (PMU) event support
...       schedule: [ on  ] - scheduler event support
...       capstone: [ on  ] - full dynamic tracing support
/uftrace # gdb tests/unittest -ex "r" -ex "bt" -ex "c" -ex "q"
GNU gdb (GDB) 10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from tests/unittest...
Starting program: /uftrace/tests/unittest 
warning: Error disabling address space randomization: Operation not permitted

Program received signal SIGSEGV, Segmentation fault.
0x000055555556ca98 in sort_tests (tc1=<optimized out>, tc2=0x7ffff71e00b0) at unittest.c:164
164             if (!strcmp(test1->name, "unittest_framework"))
#0  0x000055555556ca98 in sort_tests (tc1=<optimized out>, tc2=0x7ffff71e00b0) at unittest.c:164
#1  0x00007ffff7fb6522 in sift (head=<optimized out>, head@entry=0x7ffff71e00d0 "Z\363\377\367\377\177", width=width@entry=16, cmp=cmp@entry=0x55555556ca80 <sort_tests>, pshift=pshift@entry=2, lp=lp@entry=0x7fffffffe7f0)
    at src/stdlib/qsort.c:102
#2  0x00007ffff7fb67af in qsort (base=base@entry=0x7ffff71e0060, nel=nel@entry=74, width=width@entry=16, cmp=cmp@entry=0x55555556ca80 <sort_tests>) at src/stdlib/qsort.c:176
#3  0x000055555556c3a0 in setup_unit_test (test_num=<synthetic pointer>, test_cases=<synthetic pointer>) at unittest.c:227
#4  main (argc=1, argv=0x7fffffffed48) at unittest.c:279
Continuing.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
honggyukim commented 3 years ago

I also saw this segfault, but have no clue yet.