Skip to content

Commit caf74d7

Browse files
committed
---
yaml --- r: 6860 b: refs/heads/master c: 25f7c84 h: refs/heads/master v: v3
1 parent 5f76652 commit caf74d7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 05bf105c90e7f0dee866fb15f6616afe25fe209f
2+
refs/heads/master: 25f7c844df79a92b0de75f2ac658f31307e492c5

trunk/src/rt/rust_task.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ new_stk(rust_scheduler *sched, rust_task *task, size_t requested_sz)
123123
size_t prev_sz = (size_t)(task->stk->prev->end
124124
- (uintptr_t)&task->stk->prev->data[0]
125125
- RED_ZONE_SIZE);
126-
if (min_sz <= prev_sz) {
126+
if (min_sz <= prev_sz && requested_sz <= prev_sz) {
127127
LOG(task, mem, "reusing existing stack");
128128
task->stk = task->stk->prev;
129129
A(sched, task->stk->prev == NULL, "Bogus stack ptr");
@@ -700,7 +700,8 @@ void *
700700
rust_task::new_stack(size_t stk_sz, void *args_addr, size_t args_sz) {
701701

702702
stk_seg *stk_seg = new_stk(sched, this, stk_sz + args_sz);
703-
703+
A(sched, stk_seg->end - (uintptr_t)stk_seg->data >= stk_sz + args_sz,
704+
"Did not receive enough stack");
704705
uint8_t *new_sp = (uint8_t*)stk_seg->end;
705706
// Push the function arguments to the new stack
706707
new_sp = align_down(new_sp - args_sz);

0 commit comments

Comments
 (0)