[Development] Exceptions

Martin Storsjö martin at martin.st
Thu May 23 14:50:15 CEST 2024


On Wed, 22 May 2024, Thiago Macieira wrote:

> As far as I understand, the problem is that on ARM, there *is* no native stack
> frame, unlike on x86. Stack unwinding on x86 is very frequently possible
> because the architecture saves the return address on the stack and most code
> is compiled with frame pointers, even when exceptions are disabled. On ARM and
> other RISC architectures, the return address is saved in a register and it's
> the responsibility of the prologue of the called function to save it somewhere
> in the stack if it is not a leaf function. The problem is answering: where?
>
> This requires reading the unwind information.
>
> Which isn't present in QtWidgets.

FWIW, it is possible to build code which is unwindable, even if it doesn't 
interact with C++ exceptions, with -funwind-tables or 
-fasynchronous-unwind-tables. With either of those options, you do get 
unwind info even if compiling with -fno-exceptions.

This is also actually the default on some platforms, e.g. x86_64 and 
aarch64 linux seem to default to having this enabled (at least in Clang).

On Windows (on platforms that use SEH) this is also the case, as SEH 
unwind info is needed for handling various SEH exceptions, that may be 
used even if C++ exceptions aren't.

But on aarch64 darwin, unwind tables don't seem to be enabled by default.

(I agree with the general sentiment though; expecting to unwind through 
C++ code built with -fno-exceptions, is a very risky bet, especially as 
long as that configuration isn't continuously tested.)

// Martin



More information about the Development mailing list