File tree 1 file changed +12
-0
lines changed
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() {
64
64
// bytes pushed on the stack orginally with our return address. Using
65
65
// `8(%rsp)` simulates us testing the stack pointer in the caller's
66
66
// 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
67
74
2:
68
75
sub $$0x1000,%rsp
69
76
test %rsp,8(%rsp)
70
77
sub $$0x1000,%r11
71
78
cmp $$0x1000,%r11
72
79
ja 2b
73
80
81
+ 3:
74
82
// Finish up the last remaining stack space requested, getting the last
75
83
// bits out of r11
76
84
sub %r11,%rsp
@@ -98,13 +106,17 @@ pub unsafe extern fn __rust_probestack() {
98
106
asm ! ( "
99
107
push %ecx
100
108
mov %eax,%ecx
109
+
110
+ cmp $$0x1000,%ecx
111
+ jna 3f
101
112
2:
102
113
sub $$0x1000,%esp
103
114
test %esp,8(%esp)
104
115
sub $$0x1000,%ecx
105
116
cmp $$0x1000,%ecx
106
117
ja 2b
107
118
119
+ 3:
108
120
sub %ecx,%esp
109
121
test %esp,8(%esp)
110
122
You can’t perform that action at this time.
0 commit comments