-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SEGFAULT when using both libassert::stringify and cpptrace #103
Comments
Hi, thanks for opening this. Any segfaults are a high priority bug. I wasn't able to reproduce locally with the following setup:
Then I compiled the test program using both with
How did you compile and install libassert and cpptrace? What versions? One thing that would additionally be helpful to check is that |
I verified that cpptrace mkdir build && cd build
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX -DCPPTRACE_USE_EXTERNAL_LIBDWARF=ON
ninja install libassert mkdir build && cd build
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX -DLIBASSERT_USE_EXTERNAL_CPPTRACE=ON -DLIBASSERT_USE_EXTERNAL_MAGIC_ENUM=ON
ninja install I can give you the full Conda build config files if you'd like and I can also possibly debug this at some point on my machine but I don't have time at the moment. Here is the build environment for libassert with clang18:
|
Thanks so much, I can reproduce on an M1 Mac. I'm pasting my script below, mainly for my own remembrance. I have clang 15 and used external libdwarf, but looks like that didn't make a difference.
Edit: I was able to reproduce with Edit: And sanitizers too, fantastic |
There's something really spooky going on here. Some initial triage: There are a series of string format calls, and one fails but the others are fine. The failing one is https://github.com/jeremy-rifkin/cpptrace/blob/0742b42dadaac62436cb226a7d084738a8f82d1a/src/cpptrace.cpp#L147 str += microfmt::format(":{}", line.value()); template<typename... Args>
std::string format(const char* fmt, Args&&... args) {
return detail::format<sizeof...(args)>(fmt, fmt + std::strlen(fmt), {detail::format_value(args)...});
} template<std::size_t N, typename It>
std::string format(It fmt_begin, It fmt_end, std::array<format_value, N> args) { It's taking an array by value, there should be no possible way to see
With the One thing here is that my two libraries, libassert and cpptrace, use this microfmt code, which I'm realizing is an ODR problem. Between cpptrace 0.7.0 and libassert 2.1.0 the files match verbatim. This I don't think is ODR, but I'm going to at least namespace them differently to prevent future problems. I'm stumped as to the cause here, I'm going to have to pick things apart more in-depth. |
Ah, I understand. The format_value class differs pre/post-c++17. I’ll fix this tomorrow and create patch releases for both libraries. This is an embarrassing mistake; thank you so much for the thorough bug report! Edit to elaborate more, in case my future self or anyone else stumbles across this again: The smoking gun is https://godbolt.org/z/shbfxhbha. The std::string_view changes how the array of format_values is passed and that's a very troubling ABI break. I don't know how it ever worked on x86. |
Awesome, thanks for writing/maintaining these libraries! |
… C++17 behavior causing ODR issues, solves #103
… C++17 behavior causing ODR issues, solves #103
…C++17 behavior causing ODR issues, related to jeremy-rifkin/libassert#103
… C++17 behavior causing ODR issues, solves #103
I've released v2.1.1 with a fix for this |
Compile command
Header for all 3 snippets
Using libassert::stringify
Using cpptrace
Using both
The text was updated successfully, but these errors were encountered: