cpptrace: Stacktrace empty when catching exception on arm

Hello,

Thanks for the lib, I like the design.

I have a bug with the following snippet:

  try
  {
    throw cpptrace::runtime_error("oh noes");
  }
  catch(cpptrace::exception& e)
  {
    std::cout << e.message() << std::endl;
    e.trace().print(std::cerr, false);
    std::clog << "-- what" << std::endl;
    std::cout << e.what() << std::endl;
  }

  std::clog << "-- callback" << std::endl;
  std::clog << cpptrace::generate_trace().to_string(false) << std::endl;

It produces the following output

2024-06-05T10:37:15.945+00:00 axis-accc8e6929f3 [ ERR     ] test[25257]: Exception: oh noes
2024-06-05T10:37:16.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: Stack trace (most recent call first):
2024-06-05T10:37:16.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: <empty trace>
2024-06-05T10:37:19.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: -- what
2024-06-05T10:37:18.945+00:00 axis-accc8e6929f3 [ ERR     ] test[25257]: Exception: oh noes: Stack trace (most recent call first): <empty trace>
2024-06-05T10:37:19.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: -- callback
2024-06-05T10:37:19.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: #0 0x004828d1 in storage::subscribe(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at /opt/app/storage.cpp:61:40
2024-06-05T10:37:19.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: #1 0x0047f541 in application::setup_storage() at /opt/app/application.cpp:62:22
2024-06-05T10:37:19.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: #2 0x0047f6d9 in application::run() at /opt/app/application.cpp:27:16
2024-06-05T10:37:19.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: #3 0x0047ed0b in main at /opt/app/main.cpp:55:12
2024-06-05T10:37:19.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: #4 0x767da549 at /usr/lib/libc.so.6
2024-06-05T10:37:19.945+00:00 axis-accc8e6929f3 [ INFO    ] test[25257]: #5 0x767da5e5 at /usr/lib/libc.so.6

As you see generating the trace works but not when catching exceptions.

This is a special environment: the code is cross-compiled for armv7hf/aarch64 (it runs on AXIS cameras).

Here is the command line that builds the application:

arm-linux-gnueabihf-g++  -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/axis/acapsdk/sysroots/armv7hf -L/opt/axis/acapsdk/sysroots/armv7hf/usr/lib -O2 -g -pipe -std=c++23 -I/opt/axis/acapsdk/sysroots/armv7hf/usr/include/axsdk -I/opt/axis/acapsdk/sysroots/armv7hf/usr/include/vdo -I/opt/axis/acapsdk/sysroots/armv7hf/usr/include/gio-unix-2.0 -I/opt/axis/acapsdk/sysroots/armv7hf/usr/include/glibmm-2.68 -I/opt/axis/acapsdk/sysroots/armv7hf/usr/lib/glibmm-2.68/include -I/opt/axis/acapsdk/sysroots/armv7hf/usr/include/glib-2.0 -I/opt/axis/acapsdk/sysroots/armv7hf/usr/lib/glib-2.0/include -I/opt/axis/acapsdk/sysroots/armv7hf/usr/include/sigc++-3.0 -I/opt/axis/acapsdk/sysroots/armv7hf/usr/lib/sigc++-3.0/include -L./lib -Wl,--no-as-needed,-rpath,'$ORIGIN/lib' -lcpptrace -laxstorage -laxparameter -lvdostream -lgio-2.0 -lsystemd -lglibmm-2.68 -lgobject-2.0 -lglib-2.0 -lsigc-3.0 application.cpp main.cpp parameters.cpp storage.cpp stream.cpp -o test; \

And attached is the CMakeCache.txt that was used to build cpptrace, so you can look at the CXXFLAGS etc.

CMakeCache.txt

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Release is now out, thanks for your patience!

I’ll aim to do a patch release this weekend!

Thanks. What I really liked in your lib is just replacing std::runtime_error with cpptrace::runtime_error (etc) and have the workflow like what you’d expect.

Of course I could quickly redo them like myapp::runtime_error but the idea was to do some patching to cpptrace::exception prior to building the lib so it’d behave like your snippet above.