Skip to content

Commit 56293ad

Browse files
committed
Fix segfault on probestack with dynamic alloca.
1 parent 28daccd commit 56293ad

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/probestack.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,16 @@ pub unsafe extern fn __rust_probestack() {
6464
// bytes pushed on the stack orginally with our return address. Using
6565
// `8(%rsp)` simulates us testing the stack pointer in the caller's
6666
// context.
67+
cmp $$0x1000,%r11
68+
jna 3f
6769
2:
6870
sub $$0x1000,%rsp
6971
test %rsp,8(%rsp)
7072
sub $$0x1000,%r11
7173
cmp $$0x1000,%r11
7274
ja 2b
7375
76+
3:
7477
// Finish up the last remaining stack space requested, getting the last
7578
// bits out of r11
7679
sub %r11,%rsp
@@ -98,13 +101,17 @@ pub unsafe extern fn __rust_probestack() {
98101
asm!("
99102
push %ecx
100103
mov %eax,%ecx
104+
105+
cmp $$0x1000,%ecx
106+
jna 3f
101107
2:
102108
sub $$0x1000,%esp
103109
test %esp,8(%esp)
104110
sub $$0x1000,%ecx
105111
cmp $$0x1000,%ecx
106112
ja 2b
107113
114+
3:
108115
sub %ecx,%esp
109116
test %esp,8(%esp)
110117

0 commit comments

Comments
 (0)