-
Notifications
You must be signed in to change notification settings - Fork 805
ffi_call_unix64 kills stack frame information #12
Description
The x86-64 ABI does not require a rbp based stack frame (in fact gcc 4.6 onward by default wont emit any anymore).
It'd be a good idea to emit compatible ffi that allows walking thread via [rbp] indirections.
The primary reason for this is that it is probably impossible for libffi to emit eh_frames as defined by the dwarf standard.
Emitting proper stackframes potentially helps most code to still do proper unwinding.
The whole problem manifested, when I tried to do exception unwinding over language boundaries from within D,
which only uses bp to unwind stackframes and due to this fails at any libffi transition without any way to recover.
In particular i've set up transitions as:
D:
extern(C) void callback() { throw new SomeException(); }
int main()
{
try { callC(&callback); } catch(SomeException e) {}
}C:
funcptr _cb;
void callC(funcptr cb)
{
_cb = cb;
ffi_call(... &indirection ...),
}
void indirection()
{
_cb();
}Now indirection() as well as callback() can only see stackframes down to ffi_call_unix64 when using rbp indirection.
This makes the whole exception unwinding blow up.