MeshLib icon indicating copy to clipboard operation
MeshLib copied to clipboard

Use backtrace as a backend for boost-stacktrace

Open andrewerf opened this issue 1 year ago • 0 comments

Currently, stacktrace on linux does not provide numbers of lines. This is correct default behavior according to boost documentation, which could be modified by a flag: BOOST_STACKTRACE_USE_BACKTRACE.

However, I have experienced some issues when trying to introduce this flag in MeshLib (#3036). Namely, it works only if compiled twice.

Steps to reproduce

  1. Build ubuntu22 container from the docker folder
  2. Inside the container, run
git clone --recursive https://github.com/MeshInspector/MeshLib.git
cd MeshLib
git switch boost-use-backtrace
ln -s /usr/local/lib/meshlib-thirdparty-lib/include ./include
ln -s /usr/local/lib/meshlib-thirdparty-lib/lib ./lib
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make -j12
  1. The branch asserts on application start-up, therefore a stacktrace is printed. This build, however, does not produce line numbers. The application can be started with the following commad: ./bin/MeshViewer.
  2. Then, run the following command: cmake .. -DCMAKE_BUILD_TYPE=Debug -DMESHINSPECTOR_CUDA_SUPPORT=OFF && make -j12 (the important part is to change configuration somehow, the problem does not seem to be related to cuda specifically and the similar result could be achieved by modifying sources).
  3. This time, if started, the application produces a stacktrace with line numbers.
  4. We can do the same thing in reverse: first time compile with MESHINSPECTOR_CUDA_SUPPORT=OFF and second time without this flag, and the result will be equivalent: first-time build does not print line numbers, and second-time build does.

Thoughts

I failed to produce a MRE. Simple programs with backtrace and boost_backtrace work as expected. I think the problem is somehow related to PCH, but have not yet justified this claim.

andrewerf avatar Jul 23 '24 17:07 andrewerf