Skip to content

Commit 7f9f5ce

Browse files
committed
---
yaml --- r: 3647 b: refs/heads/master c: 91eb63e h: refs/heads/master i: 3645: ab02112 3643: b393476 3639: 19ec702 3631: ebeab8b 3615: dbfda2e 3583: c282e5e v: v3
1 parent ffcd2e7 commit 7f9f5ce

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 2f7bc90514c650fca4947835998458c56439cf33
2+
refs/heads/master: 91eb63eaee238061d278ecb8609775ac8f7aced8

trunk/src/rt/rust_kernel.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ rust_kernel::log(uint32_t level, char const *fmt, ...) {
121121
va_end(args);
122122
}
123123

124+
void
125+
rust_kernel::fatal(char const *fmt, ...) {
126+
char buf[BUF_BYTES];
127+
va_list args;
128+
va_start(args, fmt);
129+
vsnprintf(buf, sizeof(buf), fmt, args);
130+
_log.trace_ln(NULL, (uint32_t)0, buf);
131+
exit(1);
132+
va_end(args);
133+
}
134+
124135
void
125136
rust_kernel::pump_message_queues() {
126137
for (size_t i = 0; i < message_queues.length(); i++) {

trunk/src/rt/rust_kernel.h

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class rust_kernel : public rust_thread {
106106

107107
void log_all_scheduler_state();
108108
void log(uint32_t level, char const *fmt, ...);
109+
void fatal(char const *fmt, ...);
109110
virtual ~rust_kernel();
110111

111112
void *malloc(size_t size);

trunk/src/rt/rust_upcall.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@
2121
extern "C" CDECL char const *
2222
str_buf(rust_task *task, rust_str *s);
2323

24+
#ifdef __i386__
25+
void
26+
check_stack(rust_task *task) {
27+
void *esp;
28+
asm volatile("movl %%esp,%0" : "=r" (esp));
29+
if (esp < task->stk->data)
30+
task->kernel->fatal("Out of stack space, sorry");
31+
}
32+
#else
33+
#warning "Stack checks are not supported on this architecture"
34+
void
35+
check_stack(rust_task *task) {
36+
// TODO
37+
}
38+
#endif
39+
2440
extern "C" void
2541
upcall_grow_task(rust_task *task, size_t n_frame_bytes) {
2642
I(task->sched, false);
@@ -463,6 +479,7 @@ upcall_get_type_desc(rust_task *task,
463479
size_t align,
464480
size_t n_descs,
465481
type_desc const **descs) {
482+
check_stack(task);
466483
LOG_UPCALL_ENTRY(task);
467484
scoped_lock with(task->kernel->scheduler_lock);
468485
LOG(task, cache, "upcall get_type_desc with size=%" PRIdPTR

0 commit comments

Comments
 (0)