diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S index 6d67984c91b9..6e53ef850a02 100644 --- a/src/rt/arch/i386/morestack.S +++ b/src/rt/arch/i386/morestack.S @@ -53,8 +53,8 @@ MORESTACK: pushl %ebp #if defined(__linux__) || defined(__APPLE__) - .cfi_def_cfa_offset 8 - .cfi_offset %ebp, -8 + .cfi_def_cfa_offset 20 + .cfi_offset %ebp, -20 #endif movl %esp, %ebp #if defined(__linux__) || defined(__APPLE__) @@ -79,16 +79,6 @@ MORESTACK: testl %eax,%eax jz .L$bail - // During unwinding we want to skip our caller. -#if defined(__linux__) || defined(__APPLE__) - // Don't understand this line. I think it means that - // the next frame's pc is the return address of our caller. - .cfi_offset 8, 8 - // The next frame's esp is stored at our CFA - 12 - // (by the code below) - .cfi_offset %esp, -12 -#endif - // Save the the correct %esp value for our grandparent frame, // for the unwinder leal 20(%ebp), %eax @@ -156,7 +146,7 @@ MORESTACK: popl %ebp #if defined(__linux__) || defined(__APPLE__) .cfi_restore %ebp - .cfi_def_cfa %esp, 4 + .cfi_def_cfa %esp, 16 #endif retl $8 diff --git a/src/rt/arch/x86_64/morestack.S b/src/rt/arch/x86_64/morestack.S index 369e4a340e02..5378a1dcc60f 100644 --- a/src/rt/arch/x86_64/morestack.S +++ b/src/rt/arch/x86_64/morestack.S @@ -54,19 +54,11 @@ MORESTACK: // Set up a normal backtrace pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset %rbp, -16 + .cfi_def_cfa_offset 24 + .cfi_offset %rbp, -24 movq %rsp, %rbp .cfi_def_cfa_register %rbp - // During unwinding we want to skip our caller since it's not - // a complete frame and will make the unwinder sad - // Don't understand this line - .cfi_offset 16, 0 - // Tell the unwinding where to get the stack pointer for - // our grandparent frame - .cfi_offset %rsp, -24 - // Save the grandparent stack pointer for the unwinder leaq 24(%rbp), %rax pushq %rax @@ -140,7 +132,7 @@ MORESTACK: addq $8, %rsp popq %rbp .cfi_restore %rbp - .cfi_def_cfa %rsp, 8 + .cfi_def_cfa %rsp, 16 ret .cfi_endproc diff --git a/src/test/run-fail/morestack4.rs b/src/test/run-fail/morestack4.rs new file mode 100644 index 000000000000..87c5ac570ea8 --- /dev/null +++ b/src/test/run-fail/morestack4.rs @@ -0,0 +1,28 @@ +// xfail-test +// error-pattern:explicit failure +// compile-flags:--stack-growth + +// Just testing unwinding + +use std; + +native mod rustrt { + fn set_min_stack(size: uint); +} + +fn getbig_and_fail(&&i: int) { + let r = and_then_get_big_again(@0); + if i != 0 { + getbig_and_fail(i - 1); + } else { + fail; + } +} + +resource and_then_get_big_again(_i: @int) { +} + +fn main() { + rustrt::set_min_stack(256u); + task::spawn(1, getbig_and_fail); +} \ No newline at end of file