Open jeremy-rifkin opened 1 year ago
The erroneous output is from using g++-10, -std=c++11, and ubuntu-22.04
libbacktrace works by looking up a PC value in the address ranges recorded by functions. The mere presence of the function name in the info section doesn't tell us much. What matters is the associated address ranges, and whether the PC values found on the stack are in those ranges.
Is there a way that I can reproduce the problem?
Hi, thanks so much for the reply. I have my implementation at https://github.com/jeremy-rifkin/cpptrace/blob/4dac00a87f749752ca4a042c55806e71550da2e0/src/full/full_trace_with_libbacktrace.cpp and the test program at https://github.com/jeremy-rifkin/cpptrace/blob/4dac00a87f749752ca4a042c55806e71550da2e0/test/test.cpp It might be possible to reproduce with the following:
git clone https://github.com/jeremy-rifkin/cpptrace.git
git checkout 4dac00a
mkdir build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER=g++-10 \
-DCMAKE_CXX_STANDARD=11 \
-DCPPTRACE_FULL_TRACE_WITH_LIBBACKTRACE=On \
-DCPPTRACE_BUILD_TEST=On
make
./test
As an update, I was able to get at least the symbol names by falling back to backtrace_syminfo
https://github.com/jeremy-rifkin/cpptrace/blob/4dac00a87f749752ca4a042c55806e71550da2e0/src/symbols/symbols_with_libbacktrace.cpp#L59-L73 (this is a slightly different back-end that takes addresses from execinfo.h rather than backtrace_full
).
Is there a reason why the file/line information would not be retrievable but the symbol would be?
I have constructed a better reproducible example that reproduces locally for me:
/usr/bin/c++ -g -std=c++14 -fPIC -Wall -Wextra -Werror=return-type -Wshadow -o repro_lib.o -c repro_lib.cpp
/usr/bin/ar qc librepro_lib.a repro_lib.o
/usr/bin/ranlib librepro_lib.a
/usr/bin/c++ -g -fPIE -o repro.o -c repro.cpp
/usr/bin/c++ -g repro.o -o repro librepro_lib.a -lbacktrace
It is an issue with static linking it seems. Doing it as a shared library works.
/usr/bin/c++ -g -std=c++14 -fPIC -Wall -Wextra -Werror=return-type -Wshadow -o repro_lib.o -c repro_lib.cpp
/usr/bin/c++ -fPIC -g -shared -Wl,-soname,repro_lib.so -o repro_lib.so repro_lib.o -lbacktrace
/usr/bin/c++ -g -fPIE -o repro.o -c repro.cpp
/usr/bin/c++ -g repro.o -o repro -Wl,-rpath,. repro_lib.so
It looks like I'm running into the same issues when I have an executable -> a.so -> b.so (which then invokes libbacktrace).
I am trying to generate stacktraces with libbacktrace. They are working locally, but on a github workflow runner I'm seeing this
I expect to see this:
When I run
readelf --debug-dump=info test | grep foo
on the github workflow runner I get this:The symbols are present in the binary, but for some reason libbacktrace fails to resolve them. What could cause this?