Skip to content

Commit 7a8e736

Browse files
committed
rt: Make unwinding through __morestack work on mac
Had to bump the min stack size in some of the tests from 256 bytes to 1024 bytes. Not sure why yet.
1 parent 7bc34f6 commit 7a8e736

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

src/rt/arch/i386/morestack.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@
4747
#endif
4848

4949
MORESTACK:
50-
#ifdef __linux__
50+
#if defined(__linux__) || defined(__APPLE__)
5151
.cfi_startproc
5252
#endif
5353

5454
pushl %ebp
55-
#ifdef __linux__
55+
#if defined(__linux__) || defined(__APPLE__)
5656
.cfi_def_cfa_offset 8
5757
.cfi_offset %ebp, -8
5858
#endif
5959
movl %esp, %ebp
60-
#ifdef __linux__
60+
#if defined(__linux__) || defined(__APPLE__)
6161
.cfi_def_cfa_register %ebp
6262
#endif
6363

@@ -69,7 +69,7 @@ MORESTACK:
6969
jz .L$bail
7070

7171
// During unwinding we want to skip our caller.
72-
#ifdef __linux__
72+
#if defined(__linux__) || defined(__APPLE__)
7373
// Don't understand this line. I think it means that
7474
// the next frame's pc is the return address of our caller.
7575
.cfi_offset 8, 8
@@ -134,7 +134,7 @@ MORESTACK:
134134
addl $16,%esp
135135

136136
popl %ebp
137-
#ifdef __linux__
137+
#if defined(__linux__) || defined(__APPLE__)
138138
.cfi_restore %ebp
139139
.cfi_def_cfa %esp, 4
140140
#endif
@@ -150,7 +150,7 @@ MORESTACK:
150150

151151
jmpl *%edx
152152

153-
#ifdef __linux__
153+
#if defined(__linux__) || defined(__APPLE__)
154154
.cfi_endproc
155155
#endif
156156

src/rt/arch/x86_64/morestack.S

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,22 @@
5050

5151
#if defined(__linux__) || defined(__APPLE__)
5252
MORESTACK:
53-
#if defined(__ELF__)
5453
.cfi_startproc
55-
#endif
5654

5755
// Set up a normal backtrace
5856
pushq %rbp
59-
#if defined(__ELF__)
6057
.cfi_def_cfa_offset 16
6158
.cfi_offset %rbp, -16
62-
#endif
6359
movq %rsp, %rbp
64-
#if defined(__ELF__)
6560
.cfi_def_cfa_register %rbp
66-
#endif
6761

6862
// During unwinding we want to skip our caller since it's not
6963
// a complete frame and will make the unwinder sad
70-
#if defined(__linux__)
7164
// Don't understand this line
7265
.cfi_offset 16, 0
7366
// Tell the unwinding where to get the stack pointer for
7467
// our grandparent frame
7568
.cfi_offset %rsp, -24
76-
#endif
7769

7870
// Save the grandparent stack pointer for the unwinder
7971
leaq 16(%rbp), %rax
@@ -147,15 +139,11 @@ MORESTACK:
147139

148140
addq $8, %rsp
149141
popq %rbp
150-
#ifdef __linux__
151142
.cfi_restore %rbp
152143
.cfi_def_cfa %rsp, 8
153-
#endif
154144
ret
155145

156-
#if defined(__ELF__)
157146
.cfi_endproc
158-
#endif
159147

160148
#else
161149
MORESTACK:

src/test/run-fail/morestack2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ resource and_then_get_big_again(_i: ()) {
3333
}
3434

3535
fn main() {
36-
rustrt::set_min_stack(256u);
36+
rustrt::set_min_stack(1024u);
3737
std::task::spawn((), fn (&&_i: ()) {
3838
let r = and_then_get_big_again(());
3939
getbig_call_c_and_fail(10000);

src/test/run-fail/morestack3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ resource and_then_get_big_again(_i: @int) {
2929
}
3030

3131
fn main() {
32-
rustrt::set_min_stack(256u);
33-
std::task::spawn(100, getbig_and_fail);
32+
rustrt::set_min_stack(1024u);
33+
std::task::spawn(400, getbig_and_fail);
3434
}

0 commit comments

Comments
 (0)