rt: Make stack unwinding work more correctly with stack growth

This commit is contained in:
Brian Anderson 2011-12-05 17:42:58 -08:00
parent a731f165df
commit 58844aee42
3 changed files with 40 additions and 2 deletions

View File

@ -131,6 +131,9 @@ rust_task::~rust_task()
// (ref_count == 1 && this == sched->root_task));
// Delete all the stacks. There may be more than one if the task failed
// FIXME: This is not correct. During unwinding we need to delete
// the stacks and record the stack limit, otherwise the stack
// stack is corrupted when destructors are running.
while (stk != NULL) {
del_stk(this, stk);
}

View File

@ -228,8 +228,8 @@ upcall_call_shim_on_c_stack(void *args, void *fn_ptr) {
try {
sched->c_context.call_shim_on_c_stack(args, fn_ptr);
} catch (...) {
//task = rust_scheduler::get_task();
//task->record_stack_limit();
task = rust_scheduler::get_task();
task->record_stack_limit();
throw;
}
task = rust_scheduler::get_task();

View File

@ -0,0 +1,35 @@
// xfail-test
// error-pattern:explicit failure
// compile-flags:--stack-growth
// This time we're testing that the stack limits are restored
// correctly after calling into the C stack and unwinding.
// See the hack in upcall_call_shim_on_c_stack where it messes
// with the stack limit.
native mod rustrt {
fn pin_task();
}
fn getbig_call_c_and_fail(i: int) {
if i != 0 {
getbig_call_c_and_fail(i - 1);
} else {
rustrt::pin_task();
fail;
}
}
resource and_then_get_big_again(_i: ()) {
fn getbig(i: int) {
if i != 0 {
getbig(i - 1);
}
}
getbig(100000);
}
fn main() {
let r = and_then_get_big_again(());
getbig_call_c_and_fail(100000);
}