Using the setjmp
and longjmp
LLVM instrinsics did not work as expected. There is an undocumented difference between the C implementation and the LLVM intrinsics.
setjmp/longjmp (sjlj for short) is a mechanism in C that is used to handle errors, potentially deep in the call stack.
With setjmp
, the current stack frame is saved to some location in memory. Then down the line a lngjmp
can jump back to where setjmp
was called. The stack is then restored, and the return value of the setjmp
call is different between the first call, when normal execution brought use there, and a subsequent call that is the result of a jump. The different return value allows us to distinguish how we got to the setjmp
and act accordingly.