File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -64,13 +64,21 @@ 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+
68+ // It's usually called when %rax >= 0x1000, but that's not always true.
69+ // Dynamic stack allocation, which is needed to implement unsized
70+ // rvalues, triggers stackprobe even if %rax < 0x1000.
71+ // Thus we have to check %r11 first to avoid segfault.
72+ cmp $$0x1000,%r11
73+ jna 3f
6774 2:
6875 sub $$0x1000,%rsp
6976 test %rsp,8(%rsp)
7077 sub $$0x1000,%r11
7178 cmp $$0x1000,%r11
7279 ja 2b
7380
81+ 3:
7482 // Finish up the last remaining stack space requested, getting the last
7583 // bits out of r11
7684 sub %r11,%rsp
@@ -98,13 +106,17 @@ pub unsafe extern fn __rust_probestack() {
98106 asm ! ( "
99107 push %ecx
100108 mov %eax,%ecx
109+
110+ cmp $$0x1000,%ecx
111+ jna 3f
101112 2:
102113 sub $$0x1000,%esp
103114 test %esp,8(%esp)
104115 sub $$0x1000,%ecx
105116 cmp $$0x1000,%ecx
106117 ja 2b
107118
119+ 3:
108120 sub %ecx,%esp
109121 test %esp,8(%esp)
110122
You can’t perform that action at this time.
0 commit comments