r/cpp • u/Xadartt • Apr 16 '26
C++23 std::stacktrace: Never Debug Blind Again
https://medium.com/@sagar.necindia/c-23-std-stacktrace-never-debug-blind-again-6625924d520c
75
Upvotes
r/cpp • u/Xadartt • Apr 16 '26
65
u/AbroadDepot Apr 16 '26
std::stacktraceis a great feature but this article is an egregious LLM slopfest9
u/cleroth Game Developer Apr 16 '26
How does it differ from getting stack traces from mini crashdumps?
2
u/datnt84 Apr 16 '26
We already integrated it in our next version.
2
u/markt- Apr 16 '26
Yes, this is an awesome facility, but it’s only practical when memory on your system is not a constraint. There are some systems for which this is genuinely true, but they are not typically consumer devices.
2
u/PipingSnail Apr 16 '26
Hmmm. I've been debugging crashes on Unix/Linux/Windows since 1990, and I've never had a problem collecting stack traces. Whereas this article presents this as a novel solution.
If this is doing symbol handling while walking the stack, there goes your performance. Symbols should be done separately from the stack walk (unless you're walking a kernel dump/minidump when symbols make all the difference).
2
u/xealits Apr 17 '26
Reading the intro paragraph of the article, which did not mention gdb or any normal debugging methods, made me look for a Jason Turner's Weekly Cpp episode on std::stacktrace. In case someone gets the same urge, here is the link:
https://youtu.be/9IcxniCxKlQ?is=quGFBugn0ezNoyfL
2
u/jwakely libstdc++ tamer, LWG chair Apr 17 '26
The article says to use this for GCC 13.1 and later:
But that's wrong, that's only valid for GCC 13.x, for GCC 14.x and later you need to use
-lstdc++expinstead of-lstdc++_libbacktrace(and you can also use that in GCC 13.3 and later releases in the 13.3 series).So for all currently supported releases of GCC (13.4, 14.3, 15.2, and also for the soon-to-be-released 16.1), you need
-lstdc++exp1
u/13steinj Apr 18 '26
Very minor, but I don't understand the value in caching the string output for your exception if the implication is you're going to be hard crashing irrevocably anyway.
1
u/AdOnly69 Apr 16 '26
It could be useful for user logs, but for other things could we just use gdb instead of not pretending like we don't have proper tool? Also how good is std::stacktrace with multiple threads?
0
u/[deleted] Apr 16 '26
[deleted] — view deleted comment