Skip to content

Commit edf6e1e

Browse files
committed
rt: Zero the bottom frame's return address and base pointer
My reading of libunwind leads me to believe this is expected. Closes #1322
1 parent 586281e commit edf6e1e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Diff for: src/rt/arch/i386/context.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ void context::call(void *f, void *arg, void *stack) {
3131
// Shift the stack pointer so the alignment works out right.
3232
sp = align_down(sp) - 3;
3333
*--sp = (uint32_t)arg;
34-
*--sp = 0xdeadbeef;
34+
// The final return address. 0 indicates the bottom of the stack
35+
*--sp = 0;
3536

3637
regs.esp = (uint32_t)sp;
3738
regs.eip = (uint32_t)f;
39+
40+
// Last base pointer on the stack should be 0
41+
regs.ebp = 0;
3842
}
3943

4044
#if 0

Diff for: src/rt/arch/x86_64/context.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ void context::call(void *f, void *arg, void *stack) {
2828
// set up the stack
2929
uint64_t *sp = (uint64_t *)stack;
3030
sp = align_down(sp);
31-
*--sp = 0xdeadbeef; // takes place of ret. addr.
31+
// The final return address. 0 indicates the bottom of the stack
32+
*--sp = 0;
3233

3334
regs.data[RUSTRT_ARG0] = (uint64_t)arg;
3435
regs.data[RUSTRT_RSP] = (uint64_t)sp;
3536
regs.data[RUSTRT_IP] = (uint64_t)f;
37+
38+
// Last base pointer on the stack should be 0
39+
regs.data[RUSTRT_RBP] = 0;
3640
}

0 commit comments

Comments
 (0)