Skip to content

Commit bf76e00

Browse files
committed
libnative should not mess with stack limits in the TIB. Only libgreen has a legitimate need to set them.
1 parent bf420e5 commit bf76e00

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/libgreen/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ impl Context {
105105
// invalid for the current task. Lucky for us `rust_swap_registers`
106106
// is a C function so we don't have to worry about that!
107107
match in_context.stack_bounds {
108-
Some((lo, hi)) => stack::record_stack_bounds(lo, hi),
108+
Some((lo, hi)) => stack::record_stack_bounds_green(lo, hi),
109109
// If we're going back to one of the original contexts or
110110
// something that's possibly not a "normal task", then reset
111111
// the stack limit to 0 to make morestack never fail
112-
None => stack::record_stack_bounds(0, uint::MAX),
112+
None => stack::record_stack_bounds_green(0, uint::MAX),
113113
}
114114
rust_swap_registers(out_regs, in_regs)
115115
}

src/librustrt/stack.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ extern fn stack_exhausted() {
125125
}
126126

127127
#[inline(always)]
128-
pub unsafe fn record_stack_bounds(stack_lo: uint, stack_hi: uint) {
128+
pub unsafe fn record_stack_bounds_green(stack_lo: uint, stack_hi: uint) {
129129
// When the old runtime had segmented stacks, it used a calculation that was
130130
// "limit + RED_ZONE + FUDGE". The red zone was for things like dynamic
131131
// symbol resolution, llvm function calls, etc. In theory this red zone
@@ -154,6 +154,11 @@ pub unsafe fn record_stack_bounds(stack_lo: uint, stack_hi: uint) {
154154
}
155155
}
156156

157+
#[inline(always)]
158+
pub unsafe fn record_stack_bounds(stack_lo: uint, _stack_hi: uint) {
159+
record_sp_limit(stack_lo + RED_ZONE);
160+
}
161+
157162
/// Records the current limit of the stack as specified by `end`.
158163
///
159164
/// This is stored in an OS-dependent location, likely inside of the thread

0 commit comments

Comments
 (0)