Search code examples
c++windowsexception64-bit

JIT compilers and exception handling


On Windows x64, suppose there is a call chain of three functions:

function A, written in C++
function B, generated by a JIT compiler
function C, written in C++

A calls B which calls C, then C throws an exception caught by A. B is just straight-line code; it never throws or catches any exception, nor does it contain any destructors.

http://msdn.microsoft.com/en-us/library/ms235286(v=vs.80).aspx says B has to keep the stack aligned to 16 bytes, which is fine. It also says B has to be supplied with unwinding data, but isn't clear about what this data should consist of or how to supply it.

In this case where B does not actually have to do any unwinding, does it still have to have an empty unwinding data block, or can you just ignore that and have the exception silently pass over B?


Solution

  • You do need unwind data as this article explains:

    even if you just have a tiny little function that only calls another function, you still need unwind data, or when an exception occurs, your process will simply be terminated.

    The format of the unwind data is documented but it is rather terse.