rt: Various tweaks to make __morestack unwinding work on linux
When unwinding through __morestack the stack limit in the TLS is invalidated and must be reset. Instead of actually landing at __morestack we're just going to make all our Rust landing pads call upcall_reset_stack_limit, which will find the stack segment that corresponds to the current stack pointer and put the limit in the TLS. Also massively expand the stack segment red zone to make more room for the dynamic linker. Will fix in the future.
This commit is contained in:
parent
a1b215aea1
commit
9a738fd61d
10 changed files with 65 additions and 6 deletions
|
|
@ -27,7 +27,8 @@ type upcalls =
|
|||
dynastack_free: ValueRef,
|
||||
alloc_c_stack: ValueRef,
|
||||
call_shim_on_c_stack: ValueRef,
|
||||
rust_personality: ValueRef};
|
||||
rust_personality: ValueRef,
|
||||
reset_stack_limit: ValueRef};
|
||||
|
||||
fn declare_upcalls(targ_cfg: @session::config,
|
||||
_tn: type_names,
|
||||
|
|
@ -89,7 +90,8 @@ fn declare_upcalls(targ_cfg: @session::config,
|
|||
// arguments: void *args, void *fn_ptr
|
||||
[T_ptr(T_i8()), T_ptr(T_i8())],
|
||||
int_t),
|
||||
rust_personality: d("rust_personality", [], T_i32())
|
||||
rust_personality: d("rust_personality", [], T_i32()),
|
||||
reset_stack_limit: dv("reset_stack_limit", [])
|
||||
};
|
||||
}
|
||||
//
|
||||
|
|
|
|||
|
|
@ -3904,6 +3904,11 @@ fn trans_landing_pad(bcx: @block_ctxt,
|
|||
// The landing pad block is a cleanup
|
||||
SetCleanup(bcx, llpad);
|
||||
|
||||
// Because we may have unwound across a stack boundary, we must call into
|
||||
// the runtime to figure out which stack segment we are on and place the
|
||||
// stack limit back into the TLS.
|
||||
Call(bcx, bcx_ccx(bcx).upcalls.reset_stack_limit, []);
|
||||
|
||||
// FIXME: This seems like a very naive and redundant way to generate the
|
||||
// landing pads, as we're re-generating all in-scope cleanups for each
|
||||
// function call. Probably good optimization opportunities here.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue