C++ Logo

std-proposals

Advanced search

Re: Stacktrace from exception

From: Michael Knaup <michael.knaup_at_[hidden]>
Date: Thu, 29 Apr 2021 14:41:31 +0200
To me it looks like somebody here only has his view in mind.

The point is that something which comes with additional costs - and these seem to be noticeable - should not be added if it only makes sense when you‘ve specific use cases or experience.

Beside this it was already stated multiple times that exceptions are not a tool for handling bugs.

Michael



Michael Knaup
> Am 29.04.2021 um 14:28 schrieb Andrey Semashev via Std-Proposals <std-proposals_at_[hidden]>:
>
> On 4/29/21 3:22 PM, Edward Catmur wrote:
>> On Thu, 29 Apr 2021 at 13:16, Andrey Semashev via Std-Proposals <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>> wrote:
>> On 4/29/21 2:38 PM, Edward Catmur wrote:
>> > On Thu, 29 Apr 2021 at 12:22, Andrey Semashev via Std-Proposals
>> > <std-proposals_at_[hidden]
>> <mailto:std-proposals_at_[hidden]>
>> <mailto:std-proposals_at_[hidden]
>> <mailto:std-proposals_at_[hidden]>>>
>> > wrote:
>> >
>> > On 4/29/21 1:13 PM, Edward Catmur wrote:
>> > > If you're using exceptions for control flow the compiler
>> will be
>> > able to
>> > > see the whole of the program accessible from the catch block.
>> >
>> > I don't see how.
>> >
>> > Presumably your catch block is empty in that case?
>> I'm sorry, you completely lost me. How a catch block is empty and
>> yet it
>> contains std::current_exception_stacktrace call and supposedly
>> processes
>> (logs?) a stacktrace?
>> My point is that the throw site, the catch site and
>> std::current_exception_stacktrace call site can all be in different
>> TUs,
>> and the compiler cannot see all of them at once. So
>> std::current_exception_stacktrace call cannot be an indication that a
>> stacktrace needs to be collected at the throw site.
>> The TU of the throw site is irrelevant; collecting the stack trace during unwinding is performed by the runtime, not by the throwing code.
>
> Presumably, someone has to tell the runtime to collect the stacktrace, and, if I understood you right, that someone is supposed to be the compiler, which sees a std::current_exception_stacktrace call in the catch block.
>
>> If the catch site calls outside its own TU then yes, the compiler should assume that it may access the exception stack trace. But if it's being used for control flow then it won't call outside its own TU since the exception is expected.
>
> I don't see how you arrive to this conclusion. And a catch handler absolutely will contain a call to a different TU, even if to merely log the event.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2021-04-29 07:41:35