diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2014-10-23 07:29:41 +0200 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2014-10-24 14:36:29 +0200 |
| commit | 70cef9474a3307ec763efc01fe6969e542083823 (patch) | |
| tree | d555ef3ddf5fb14c6e28ba10b61708f53c0721af /src/libnative | |
| parent | 50e86c26e0aa292e5e0452abd1830741f5bb525e (diff) | |
| download | rust-70cef9474a3307ec763efc01fe6969e542083823.tar.gz rust-70cef9474a3307ec763efc01fe6969e542083823.zip | |
Print stack overflow messages for Windows, Linux and OS X
Fixes #17562
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/lib.rs | 3 | ||||
| -rw-r--r-- | src/libnative/task.rs | 15 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index 656c7e4103c..c99143f0a5d 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -132,7 +132,8 @@ pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int { rt::init(argc, argv); let mut exit_code = None; let mut main = Some(main); - let mut task = task::new((my_stack_bottom, my_stack_top)); + let mut task = task::new((my_stack_bottom, my_stack_top), + rt::thread::main_guard_page()); task.name = Some(str::Slice("<main>")); drop(task.run(|| { unsafe { diff --git a/src/libnative/task.rs b/src/libnative/task.rs index d90535428da..455656c09d4 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -29,10 +29,11 @@ use io; use std::task::{TaskBuilder, Spawner}; /// Creates a new Task which is ready to execute as a 1:1 task. -pub fn new(stack_bounds: (uint, uint)) -> Box<Task> { +pub fn new(stack_bounds: (uint, uint), stack_guard: uint) -> Box<Task> { let mut task = box Task::new(); let mut ops = ops(); ops.stack_bounds = stack_bounds; + ops.stack_guard = stack_guard; task.put_runtime(ops); return task; } @@ -44,6 +45,7 @@ fn ops() -> Box<Ops> { io: io::IoFactory::new(), // these *should* get overwritten stack_bounds: (0, 0), + stack_guard: 0 } } @@ -82,6 +84,7 @@ impl Spawner for NativeSpawner { my_stack); } let mut ops = ops; + ops.stack_guard = rt::thread::current_guard_page(); ops.stack_bounds = (my_stack - stack + 1024, my_stack); let mut f = Some(f); @@ -115,6 +118,8 @@ struct Ops { // native tasks necessarily know their precise bounds, hence this is // optional. stack_bounds: (uint, uint), + + stack_guard: uint } impl rt::Runtime for Ops { @@ -138,6 +143,14 @@ impl rt::Runtime for Ops { fn stack_bounds(&self) -> (uint, uint) { self.stack_bounds } + fn stack_guard(&self) -> Option<uint> { + if self.stack_guard != 0 { + Some(self.stack_guard) + } else { + None + } + } + fn can_block(&self) -> bool { true } // This function gets a little interesting. There are a few safety and |
