C++ Logo


Advanced search

Re: Adding stacktrace to std::exception

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Fri, 13 Nov 2020 17:26:29 +0300
On 11/13/20 11:56 AM, Marcin Jaczewski via Std-Proposals wrote:
> pt., 13 lis 2020 o 07:54 Thiago Macieira via Std-Proposals
> <std-proposals_at_[hidden]> napisaƂ(a):
>> On Thursday, 12 November 2020 06:14:52 PST Antony Polukhin via Std-Proposals
>> wrote:
>>> 1) Implement __cxa_allocate_exception2 that allocates (see note 0)
>>> additional space (see note 1) to store the stacktrace AND puts a mark
>>> (see note 2) into the allocated memory, that this is an exception with
>>> a stacktrace
>> Another note: one condition for throwing exceptions is being out of memory. So
>> the implementation must figure out how to throw an exception when it can't
>> allocate space for the stack trace.
>> 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.

There will always be someone, for whom it will not be enough. I'd say, a
means to limit the stacktrace depth would be useful, but it should not
be hardcoded, it should be specifiable by the user, and the full
stacktrace should be obtainable and the default.

Received on 2020-11-13 08:26:36