[cfe-dev] SEH unwind info for function dividing by zero

David Chisnall via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 11 02:34:09 PDT 2018


On 11 Apr 2018, at 09:24, Jayvee Neumann via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> I am currently using clang++ on windows with the target triple x86_64-pc-windows-gnu. If I write a small function that performs a division (which can result in a division by Zero) I would expect SEH unwind information for that function. As far as I know that information is crucial for unwinding the stack after e.g. a division by zero. The flag "-fasynchronous-unwind-tables" did not help.
> 
> Does this correspond to the note on https://clang.llvm.org/docs/MSVCCompatibility.html stating the following?
> 
> > Asynchronous Exceptions (SEH): Partial. Structured exceptions 
> > (__try / __except / __finally) mostly work on x86 and x64. 
> > LLVM does not model asynchronous exceptions, so it is currently 
> > impossible to catch an asynchronous exception generated in the 
> > same frame as the catching __try.
> 
> Is there a work-around helping the unwinding of the stack without SEH unwind info or am I missing something?

You specifically need non-call exceptions, which LLVM does not support.  These provide a very nice programming model, but cause massive pain for the compiler because any instruction can have the side effect of flow control, which the compiler must model.  The exception landing pad must be able to cope with jumps not just from function calls, but from any instruction that may trap (loads, stores, divides, any floating point instruction) and must handle register values that it needs not being live at that point.  This is very difficult to support and so is not yet in LLVM, with the exception of a special case for dereferencing null pointers (which clang doesn’t use, though probably could on Windows if required, but which is used by some a Java implementation to generate Java NullPointerExceptions without explicit checks).

David




More information about the cfe-dev mailing list