From edf6e1ec0e038b805a36a7e3689b37fc3cea7387 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 19 Dec 2011 18:36:09 -0800 Subject: [PATCH] rt: Zero the bottom frame's return address and base pointer My reading of libunwind leads me to believe this is expected. Closes #1322 --- src/rt/arch/i386/context.cpp | 6 +++++- src/rt/arch/x86_64/context.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/rt/arch/i386/context.cpp b/src/rt/arch/i386/context.cpp index f5fa3777eec3..e65420dc0e31 100644 --- a/src/rt/arch/i386/context.cpp +++ b/src/rt/arch/i386/context.cpp @@ -31,10 +31,14 @@ void context::call(void *f, void *arg, void *stack) { // Shift the stack pointer so the alignment works out right. sp = align_down(sp) - 3; *--sp = (uint32_t)arg; - *--sp = 0xdeadbeef; + // The final return address. 0 indicates the bottom of the stack + *--sp = 0; regs.esp = (uint32_t)sp; regs.eip = (uint32_t)f; + + // Last base pointer on the stack should be 0 + regs.ebp = 0; } #if 0 diff --git a/src/rt/arch/x86_64/context.cpp b/src/rt/arch/x86_64/context.cpp index d9070c6385a2..46a606c6c6e0 100644 --- a/src/rt/arch/x86_64/context.cpp +++ b/src/rt/arch/x86_64/context.cpp @@ -28,9 +28,13 @@ void context::call(void *f, void *arg, void *stack) { // set up the stack uint64_t *sp = (uint64_t *)stack; sp = align_down(sp); - *--sp = 0xdeadbeef; // takes place of ret. addr. + // The final return address. 0 indicates the bottom of the stack + *--sp = 0; regs.data[RUSTRT_ARG0] = (uint64_t)arg; regs.data[RUSTRT_RSP] = (uint64_t)sp; regs.data[RUSTRT_IP] = (uint64_t)f; + + // Last base pointer on the stack should be 0 + regs.data[RUSTRT_RBP] = 0; }