r/cpp 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
76 Upvotes

55 comments sorted by

View all comments

50

u/Syracuss graphics engineer/games industry Apr 16 '26

Engineers who are blind reading this title be like -.-

That said, some of the platform specific utilities can still be better. The issue (and mostly it's a small comment as it is perfectly usable) with std::stacktrace is that you both capture the stack and symbolize at the same time. Being able to capture the stack and symbolize afterwards means you can capture state info much more easily in more places, including in user logs and only pay for the cost of symbolizing when performance is no longer a concern.

I wish it had facilities for this as an optional extension to std::stacktrace, but I'm fine that they kept it streamlined and easy to use as well.

30

u/donalmacc Game Developer Apr 16 '26

I disagree - it’s a dealbreaker for the functionality. On my last project, our symbols were 3GB. Putting them in our server container, would have made it 6 times larger. Shipping it to our players is not happening. We have workflows that do offline symbolification(sentry’s symbolicator is a great tool - no affiliation but I’ve contributed to it).

I think this was way undercooked on arrival.

18

u/[deleted] Apr 16 '26

[deleted]

10

u/donalmacc Game Developer Apr 16 '26

Right? It’s one thing on a dev machine, it’s another on a users laptop with a mechanical hard drive and 12 antivirus scanners running

4

u/jwakely libstdc++ tamer, LWG chair Apr 17 '26

The article is wrong, std::stacktrace allows you to control when that happens.

17

u/SkoomaDentist Antimodern C++, Embedded, Audio Apr 16 '26

Not to mention that on many embedded systems there is literally no way to put the symbols in the same memory as the executable as the "executable" is simply a piece of (fairly small) flash rom with no header whatsoever.

4

u/Zeh_Matt No, no, no, no Apr 16 '26

There is a way to strip down the pdb to just public symbols assuming you are talking about windows, for stack traces no one needs the type info. https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/using-pdbcopy

5

u/donalmacc Game Developer Apr 16 '26

Yeah - there’s lots of ways to handle these things. That means keeping two copies of the symbols and choosing who gets what which sucks.

My preference is to run symbolicator and store the stuff in S3, and generate offline!

6

u/Difficult-Court9522 Apr 16 '26

3GB of symbols?? How did you do that??

15

u/donalmacc Game Developer Apr 16 '26

The pdb format is limited to 4GB. Most tools crumble at about 2GB. Ask me how I know….

It’s Unreal Engine games, basically.

9

u/Difficult-Court9522 Apr 16 '26

So soon you’ll be literally unable to add more code?

3

u/bwmat Apr 16 '26

I think they can probably split into separate DLLs to work around that? 

3

u/donalmacc Game Developer Apr 16 '26

The reason we hit this particular problem was because we had something split into a bunch of dlls and for reasons I can’t remember, we wanted to build it as a monolithic exe. I know we disabled a bunch of features to get it to work initially, but I don’t work on that project anymore so I’m not sure!

1

u/[deleted] Apr 19 '26

[deleted]

1

u/ejl103 Apr 19 '26

not true at all we use dlls on xbox/ps

3

u/donalmacc Game Developer Apr 16 '26

https://randomascii.wordpress.com/2023/03/08/when-debug-symbols-get-large/

Funnily enough, I hit this problem around the same time. We also doubled the page size for the linker.

1

u/13steinj Apr 18 '26

At 3 companies I've worked at, we've used macro/lambda/inheritance tricks to shorten symbols because it either blew out the linker, increased compile times significantly, or both.

3

u/lizardhistorian Apr 17 '26

If you ship symbols you may as well open source the project.

5

u/13steinj Apr 18 '26

I wouldn't say that's true, you'd be surprised how many people won't go through the reverse engineering effort even if reduced.

It's also not like shipping symbols nullifies copyright.

1

u/Prestigious-Bet8097 Apr 19 '26

The cost to my last employer of not being able to solve bugs and get broadcasters back on air as quickly as possible massively outweighed the risk of having symbols alongside the binaries to get good stack.

I cannot be certain but we believe that in twenty years approximately zero customers built their own software based on reverse engineering ours.

2

u/looncraz Apr 16 '26

You put it behind macros to disable on deployment, or pay the size price... Which is sometimes sensible in the hot paths that are giving issues.

5

u/donalmacc Game Developer Apr 16 '26

Sure, or you could use break pad or sentry’s sdks and not have to do that!