Skip to content

Commit 2d13172

Browse files
committed
---
yaml --- r: 188112 b: refs/heads/auto c: 243c516 h: refs/heads/master v: v3
1 parent fcc3bde commit 2d13172

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 185c074798ce87429118868c292d2c2c7dc46cfc
13+
refs/heads/auto: 243c5164ea32b38c4ac44fdd5e0ceb2da45c283f
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libstd/rt/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use marker::Send;
2727
use ops::FnOnce;
2828
use sys;
2929
use thunk::Thunk;
30+
use usize;
3031

3132
// Reexport some of our utilities which are expected by other crates.
3233
pub use self::util::{default_sched_threads, min_stack, running_on_valgrind};
@@ -78,7 +79,20 @@ fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int {
7879
// FIXME #11359 we just assume that this thread has a stack of a
7980
// certain size, and estimate that there's at most 20KB of stack
8081
// frames above our current position.
81-
let my_stack_bottom = my_stack_top + 20000 - OS_DEFAULT_STACK_ESTIMATE;
82+
const TWENTY_KB: uint = 20000;
83+
84+
// saturating-add to sidestep overflow
85+
let top_plus_spill = if usize::MAX - TWENTY_KB < my_stack_top {
86+
usize::MAX
87+
} else {
88+
my_stack_top + TWENTY_KB
89+
};
90+
// saturating-sub to sidestep underflow
91+
let my_stack_bottom = if top_plus_spill < OS_DEFAULT_STACK_ESTIMATE {
92+
0
93+
} else {
94+
top_plus_spill - OS_DEFAULT_STACK_ESTIMATE
95+
};
8296

8397
let failed = unsafe {
8498
// First, make sure we don't trigger any __morestack overflow checks,

0 commit comments

Comments
 (0)