C++ Logo

std-proposals

Advanced search

Re: Adding stacktrace to std::exception

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 13 Nov 2020 08:24:13 -0800
On Friday, 13 November 2020 00:56:39 PST Marcin Jaczewski wrote:
> > Also, stack traces' size are not known at compile time, unlike exceptions
> > classes.
>
> Do we need a full stack trace to be this useful?
> Let say that Standard guarantees only last 20 positions from it.
> Rest will be available only if there is free memory for it.

Don't ask me. But this is a reasonable question: what is the minimum viable
solution in case memory allocation fails? Is a backtrace simply a pointer per
frame?

Note that increasing the size of the emergency per-thread exception buffer
means memory gets allocated for everyone, whether they use it or not. There's
a cost in this. Adding 20 pointers (160 bytes) may not be too bad, except ...
you know... when you're out of memory. So the fact that you reserved space for
when you're out of memory could be the cause that you're out of memory.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2020-11-13 10:24:18