-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit f46b255
std: detect stack overflows in TLS destructors on UNIX
Fixes #111272.
With #127912 merged, we now have all the infrastructure in place to support stack overflow detection in TLS destructors. This was not possible before because the signal stack was freed in the thread main function, thus a SIGSEGV afterwards would immediately crash. And on platforms without native TLS, the guard page address was stored in an allocation freed in a TLS destructor, so would not be available. #127912 introduced the `local_pointer` macro which allows storing a pointer-sized TLS variable without allocation and the `thread_cleanup` runtime function which is called after all other code managed by the Rust runtime. This PR simply moves the signal stack cleanup to the end of `thread_cleanup` and uses `local_pointer` to store every necessary variable. And so, everything run under the Rust runtime is now properly protected against stack overflows.1 parent 11ee3a8 commit f46b255
13 files changed
+196
-177
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
117 | 117 |
| |
118 | 118 |
| |
119 | 119 |
| |
120 | + | ||
120 | 121 |
| |
121 | 122 |
| |
122 | 123 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
72 | + | ||
73 | + | ||
72 | 74 |
| |
73 | 75 |
| |
74 | 76 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
40 | + | ||
41 | + | ||
40 | 42 |
| |
41 | 43 |
| |
42 | 44 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
41 | + | ||
42 | + | ||
41 | 43 |
| |
42 | 44 |
| |
43 | 45 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
40 | + | ||
41 | + | ||
40 | 42 |
| |
41 | 43 |
| |
42 | 44 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
77 | 77 |
| |
78 | 78 |
| |
79 | 79 |
| |
80 | + | ||
81 | + | ||
80 | 82 |
| |
81 | 83 |
| |
82 | 84 |
| |
|
Lines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
57 | - | ||
57 | + | ||
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
| |||
228 | 228 |
| |
229 | 229 |
| |
230 | 230 |
| |
231 | - | ||
232 | - | ||
233 | - | ||
231 | + | ||
234 | 232 |
| |
235 | 233 |
| |
236 | 234 |
| |
235 | + | ||
236 | + | ||
237 | + | ||
238 | + | ||
237 | 239 |
| |
238 | 240 |
| |
239 | 241 |
| |
|
0 commit comments