jeremy-rifkin / cpptrace

Simple, portable, and self-contained stacktrace library for C++11 and newer
MIT License
642 stars 67 forks source link

sigsegv if -glldb specified with clang #86

Closed larkwiot closed 7 months ago

larkwiot commented 7 months ago

Hey, love your libraries!

I don't think this is really an issue with cpptrace, but it's an issue that I think is likely to come up when someone uses it incorrectly so I wanted to document it.

I am using a very new version of clang and had specified -glldb at some point in my CMakePresets, which caused a sigsegv when trying to unwind with libdwarf. When stated like that the issue is obvious, but it took me a bit to find since it was only throwing an exception that triggered the problem.

The solution is to switch your compile argument to something like -gdwarf-4 so that libdwarf can unwind the trace.

I'll leave this issue open in case there is any action you do want to take on it, but feel free to close it if you agree that this issue is not the responsibility of cpptrace to handle.

jeremy-rifkin commented 7 months ago

Hi thank you for opening this issue! Segfaults are definitely undesirable, I will try to reproduce and fix this.

jeremy-rifkin commented 7 months ago

I've tried reproducing with clang 17 with -glldb on ubuntu but I've been unsuccessful. If there's any additional information you could provide it would be very helpful! (information about your setup, a reproducible example, a binary I could look at, or even a backtrace in gdb to better understand where things are going wrong internally)

larkwiot commented 7 months ago

I've tried reproducing with clang 17 with -glldb on ubuntu but I've been unsuccessful. If there's any additional information you could provide it would be very helpful! (information about your setup, a reproducible example, a binary I could look at, or even a backtrace in gdb to better understand where things are going wrong internally)

Sure! I'll see if I can get a minimal environment for you.

larkwiot commented 7 months ago

I've tried reproducing with clang 17 with -glldb on ubuntu but I've been unsuccessful. If there's any additional information you could provide it would be very helpful! (information about your setup, a reproducible example, a binary I could look at, or even a backtrace in gdb to better understand where things are going wrong internally)

It seems the issue only occurs in the context of a Catch2 test case. Here's a minimal repo you can fiddle with: https://github.com/larkwiot/cpptrace-glldb-segfault

I am using Clang 16.0.6 on Manjaro (Arch-based).

jeremy-rifkin commented 7 months ago

Thanks so much, that's fantastic! I am able to reproduce and I'm looking into it now.

jeremy-rifkin commented 7 months ago

This should be resolved now on the dev branch, and I'll look to do a 0.4.1 patch soon. I've addressed the edge case however there seems to be some odd behavior at play that I can't fully explain yet. I am somewhat suspecting a libdwarf bug.

larkwiot commented 7 months ago

Thank you for your hard work and excellent library!

jeremy-rifkin commented 7 months ago

I appreciate the kind words, I'm so happy it's helpful to you 😄

jeremy-rifkin commented 6 months ago

Fix is now in main