main [so: 14]: contrib/llvm-project/libunwind/src/Unwind-EHABI.cpp:915 failure in armv7 context

From: Mark Millard via freebsd-arm <freebsd-arm_at_freebsd.org>
Date: Sat, 27 Nov 2021 17:49:39 UTC
In tracking down a armv7 build failure for some ports
the fail during rustc, I managed to get a gdb backtrace
for an example .core finally. This is based on not
striping (no debug information). (rustc's build in
armv7 contexts attempt links that fail for lack of a
sufficient process address space.)

The thing is that the .core file is generated during
rustc itself attempting to do a backtrace for its
internal failure. The gdb backtrace shows the
top-of-call-stack (larger address) stack frames as
being in FreeBSD code. The freeBSD builds involved
are a non-debug builds but with debug information
present.


Note that the thread involved is not the main thread but
one created via  _pthread_create instead.

Also note that the SIGSEGV happened at:

/usr/main-src/contrib/llvm-project/libunwind/src/Unwind-EHABI.cpp:915

which looks like:

915             uint32_t value = *sp++;

I could get the other source lines for the FreeBSD call frames if
needed.


gdb reports:

Core was generated by `/usr/local/bin/rustc --crate-name tempfile --edition=2018 /wrkdirs/usr/ports/dev'.
Program terminated with signal SIGSEGV, Segmentation fault.
Address not mapped to object.
#0  _Unwind_VRS_Pop (context=0xbfff5b80, regclass=_UVRSC_CORE, discriminator=18432, representation=_UVRSD_UINT32) at /usr/main-src/contrib/llvm-project/libunwind/src/Unwind-EHABI.cpp:915
915             uint32_t value = *sp++;
[Current thread is 1 (LWP 710038)]
(gdb) bt
#0  _Unwind_VRS_Pop (context=0xbfff5b80, regclass=_UVRSC_CORE, discriminator=18432, representation=_UVRSD_UINT32) at /usr/main-src/contrib/llvm-project/libunwind/src/Unwind-EHABI.cpp:915
#1  _Unwind_VRS_Interpret (context=0xbfff5b80, data=<optimized out>, offset=4, len=4) at /usr/main-src/contrib/llvm-project/libunwind/src/Unwind-EHABI.cpp:281
#2  0x400c83e0 in libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm>::stepWithEHABI (this=0xbfff5b80)
    at /usr/main-src/contrib/llvm-project/libunwind/src/UnwindCursor.hpp:921
#3  libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm>::step (this=0xbfff5b80) at /usr/main-src/contrib/llvm-project/libunwind/src/UnwindCursor.hpp:2094
#4  0x400c7134 in (anonymous namespace)::unwindOneFrame (state=<optimized out>, ucbp=0xbfff59d8, context=0xbfff5b80) at /usr/main-src/contrib/llvm-project/libunwind/src/Unwind-EHABI.cpp:190
#5  0x400c7708 in _Unwind_Backtrace (callback=0x47346bc0 <std::backtrace_rs::backtrace::libunwind::trace::trace_fn>, ref=0xbfff5d58)
    at /usr/main-src/contrib/llvm-project/libunwind/src/UnwindLevel1-gcc-ext.c:156
#6  0x47311b58 in std::backtrace::Backtrace::create () from /usr/local/lib/libstd-21f5f79d0bba7291.so
#7  0x47311ac8 in std::backtrace::Backtrace::force_capture () from /usr/local/lib/libstd-21f5f79d0bba7291.so
#8  0x46c61f28 in rustc_errors::Handler::delay_good_path_bug () from /usr/local/lib/librustc_driver-a196dfc434d07325.so
#9  0x46a33998 in rustc_middle::ty::print::pretty::trimmed_def_paths::h696a2e73b4fe3316 () from /usr/local/lib/librustc_driver-a196dfc434d07325.so
. . .
#42 0x401371ac in thread_start (curthread=0x40073a00) at /usr/main-src/lib/libthr/thread/thr_create.c:292
#43 0x40136cdc in _pthread_create (thread=0xffffb0b8, attr=<optimized out>, start_routine=<optimized out>, arg=<optimized out>) at /usr/main-src/lib/libthr/thread/thr_create.c:187
#44 0x40139a4c in _thr_umutex_unlock2 (mtx=0x0, id=11, defer=0x0) at /usr/main-src/lib/libthr/thread/thr_umtx.h:160
#45 _thr_umutex_unlock (mtx=0x0, id=11) at /usr/main-src/lib/libthr/thread/thr_umtx.h:183Backtrace stopped: Cannot access memory at address 0x4


For reference:

# uname -apKU
FreeBSD CA72_16Gp_ZFS 14.0-CURRENT FreeBSD 14.0-CURRENT #22 main-n250972-319e9fc642a1-dirty: Tue Nov 23 12:25:36 PST 2021     root@CA72_16Gp_ZFS:/usr/obj/BUILDs/main-CA72-nodbg-clang/usr/main-src/arm64.aarch64/sys/GENERIC-NODBG-CA72  arm64 aarch64 1400042 1400042

# poudriere jail -jmain-CA7 -i
Jail name:         main-CA7
Jail version:      14.0-CURRENT
Jail arch:         arm.armv7
Jail method:       null
Jail mount:        /usr/obj/DESTDIRs/main-CA7-poud
Jail fs:           
Jail updated:      2021-06-27 17:58:33
Jail pkgbase:      disabled

# uname -apKU
FreeBSD CA72_16Gp_ZFS 14.0-CURRENT FreeBSD 14.0-CURRENT #22 main-n250972-319e9fc642a1-dirty: Tue Nov 23 12:25:36 PST 2021     root@CA72_16Gp_ZFS:/usr/obj/BUILDs/main-CA72-nodbg-clang/usr/main-src/arm64.aarch64/sys/GENERIC-NODBG-CA72  arm armv7 1400042 1400042

The backtracking also fails for releng/13.0 (-p5) poudriere
jail targeting armv7 but some details are different that make
it more complicated to deal with. I've only gone after
gathering and reporting evidence from the simpler context
that gets the somewhat earlier failure.

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)