boostorg / stacktrace

C++ library for storing and printing backtraces.
https://boost.org/libs/stacktrace
433 stars 74 forks source link

Stack symbolization depends on where the source files resides #174

Closed subbota-a closed 1 month ago

subbota-a commented 3 months ago

For some reasons I started to use stacktrace library injecting the source files to my project. And it turned out that the result depends on how to build the project.

/project
---/stacktrace
---   backtrace.cpp
---   from_exception.cpp
---   CMakeLists.txt which add_library(stacktrace  backtrace.cpp from_exception.cpp)
  test.cpp
  CMakeLists.txt

And I build two versions of executable:

  1. add_executable(ver1 test.cpp stacktrace/backtrace.cpp stacktrace/from_exception.cpp)
  2. add_executable(ver2 test.cpp) + target_link_libraries(ver2 stacktrace)

The ver1 shows stack as

 0# foo() in /opt/test
 1# main in /opt/test
 2# 0x00007FE22EAA8D90 in /lib/x86_64-linux-gnu/libc.so.6
 3# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
 4# _start in /opt/test

The ver2 show stack as

 0# 0x000055FEA0E2D528 in /opt/test
 1# 0x000055FEA0E2CA13 in /opt/test
 2# 0x00007F11801E7D90 in /lib/x86_64-linux-gnu/libc.so.6
 3# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
 4# 0x000055FEA0E2C905 in /opt/test

Can you help me to understand what's going on?

Code for reproduction is here I use clang-17 and libc++

apolukhin commented 1 month ago

What are the build flags?

What version of stacktrace library are you using in 2. and with which implementation do you link (backtrace, noop, add2line...?)

subbota-a commented 1 month ago

Everyone involved in the issue died a long time ago, so I'm closing the question.