diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-07-06 15:06:30 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-07-06 15:07:04 -0700 |
| commit | 91eb63eaee238061d278ecb8609775ac8f7aced8 (patch) | |
| tree | 8a42a6cb705bcde49f17c9d3a114a36bf1d8bbf5 /src/rt/rust_upcall.cpp | |
| parent | 2f7bc90514c650fca4947835998458c56439cf33 (diff) | |
| download | rust-91eb63eaee238061d278ecb8609775ac8f7aced8.tar.gz rust-91eb63eaee238061d278ecb8609775ac8f7aced8.zip | |
rt: Add a stack check to upcall_get_type_desc
Diffstat (limited to 'src/rt/rust_upcall.cpp')
| -rw-r--r-- | src/rt/rust_upcall.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 05220f02606..d8ff9236aa6 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -21,6 +21,22 @@ extern "C" CDECL char const * str_buf(rust_task *task, rust_str *s); +#ifdef __i386__ +void +check_stack(rust_task *task) { + void *esp; + asm volatile("movl %%esp,%0" : "=r" (esp)); + if (esp < task->stk->data) + task->kernel->fatal("Out of stack space, sorry"); +} +#else +#warning "Stack checks are not supported on this architecture" +void +check_stack(rust_task *task) { + // TODO +} +#endif + extern "C" void upcall_grow_task(rust_task *task, size_t n_frame_bytes) { I(task->sched, false); @@ -463,6 +479,7 @@ upcall_get_type_desc(rust_task *task, size_t align, size_t n_descs, type_desc const **descs) { + check_stack(task); LOG_UPCALL_ENTRY(task); scoped_lock with(task->kernel->scheduler_lock); LOG(task, cache, "upcall get_type_desc with size=%" PRIdPTR |
