Not being a proficient Linux programmer, I wondered what other means than learning gdb intrinsics I had to get more information about a segmentation fault.
A while back, pip list 2> /dev/null would cause a segmentation fault on my system (see [WayBack] Bug 1084812 – [aarch64] IPv4 DNS leading to segfaults).
It turns out that LD_PRELOAD was my friend (like TERM=xterm was a friend before):
LD_PRELOAD=libSegFault.so pip list 2> /dev/null
It indicated that the problem was in libc, which on opensuse is implemented by glibc.
This meant that the originally diagnosed problem was already accurately describing the symptoms.
Searching for glibc libSegFault.so didn’t reveal many useful links, so I’ve included the one making most sense to me here:
- [WayBack] /root/tech_memoirs: Catching segmentation fault, it’s analysis & bunch of other stuff
- [WayBack] stack trace – Can one use libSegFault.so to get backtraces for SIGABRT? – Stack Overflow
- [WayBack] c – What is the LD_PRELOAD trick? – Stack Overflow
- [WayBack] All about LD_PRELOAD « Musings
- [WayBack] What is preloading? • Andreas Schneider
The cool thing: most of the links above come from [WayBack] segmentation fault – Can you get any program in Linux to print a stack trace if it segfaults? – Server Fault which I found when searching for linux find segmentation fault stack trace
That link explains both the LD_PRELOAD steps and gdb steps (:
- [WayBack] Catching SIGSEGVs as they happen — Prefetch Technologies
- [Archive.is/WayBack] Obtaining a stack trace in C upon SIGSEGV – From TLUGWiki
- [WayBack] How to debug a GCC segmentation fault – GNU Project – Free Software Foundation (FSF)
An alternative is to use gdb directly: [WayBack] command line arguments – How do I run a program with commandline args using gdb within a bash script? – Stack Overflow:
gdb -ex=run --args pip list
--jeroen





