Skip to content

Commit b42c6d0

Browse files
committed
rt: Don't limit the amount of stack available during unwinding. Closes #2144
1 parent a1d5970 commit b42c6d0

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/rt/rust_task.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,17 @@ rust_task::new_stack(size_t requested_sz) {
514514

515515
if (total_stack_sz + rust_stk_sz > kernel->env->max_stack_size) {
516516
LOG_ERR(this, task, "task %" PRIxPTR " ran out of stack", this);
517-
fail();
517+
if (!unwinding) {
518+
fail();
519+
} else {
520+
// FIXME: Because we have landing pads that may need more
521+
// stack than normally allowed we have to go allow the stack
522+
// to grow unbounded during unwinding. Would be nice to
523+
// have a different solution - maybe just double the limit.
524+
LOG_ERR(this, task, "task %" PRIxPTR " has blown its stack "
525+
"budget but we are unwinding so growing the stack "
526+
"anyway");
527+
}
518528
}
519529

520530
size_t sz = rust_stk_sz + RED_ZONE_SIZE;

src/test/run-fail/issue-2144.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// error-pattern:ran out of stack
2+
3+
// Don't leak when the landing pads need to request more stack
4+
// than is allowed during normal execution
5+
6+
fn useBlock(f: fn~() -> uint) { useBlock({|| 22u }) }
7+
fn main() {
8+
useBlock({|| 22u });
9+
}

0 commit comments

Comments
 (0)