Commit d05bbe4
[release/7.0] Prevent unwinding through stack bottom (#81804)
* Prevent unwinding through stack bottom
When processing unhandled exception on the most recent Alpine 3.17,
the libunwind doesn't stop at the bottom
frame of the main thread (the caller of `main`) and tries to unwind
further. The reason is that the method is missing dwarf unwind
information, so the libunwind falls back to using RBP chain, but the RBP
points to a garbage and so it ends up crashing with SIGSEGV.
While the missing DWARF unwind info seems to be a bug in the Alpine 3.17
(older ones work fine), we can prevent issues like this by stopping at
the hosting API boundary and not trying to unwind past that. This is
what this PR does.
* Fix bug introduced by preventing unwind through stack bottom (#81956)
The irecent fix to prevent unwinding through stack bottom was
incorrect for secondary threads, as it just compared the SP
being above the frame of the hosting API. However, other threads
can have their stacks anywhere in the memory, thus this
sometimes broke exception handling on secondary threads.
I have also found that there was one more case where the
unwind through the hosting API need to be checked - the
Thread::VirtualUnwindToFirstManagedCallFrame.
I have decided to use the return address of the hosting
API for the checks instead of the frame address. That
makes the check work properly.
---------
Co-authored-by: Jan Vorlicek <[email protected]>1 parent a1136a9 commit d05bbe4
File tree
3 files changed
+37
-2
lines changed- src/coreclr
- dlls/mscoree
- vm
3 files changed
+37
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
26 | 45 | | |
27 | 46 | | |
28 | 47 | | |
| |||
194 | 213 | | |
195 | 214 | | |
196 | 215 | | |
| 216 | + | |
197 | 217 | | |
198 | 218 | | |
199 | 219 | | |
| |||
212 | 232 | | |
213 | 233 | | |
214 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
215 | 239 | | |
216 | 240 | | |
217 | 241 | | |
| |||
420 | 444 | | |
421 | 445 | | |
422 | 446 | | |
| 447 | + | |
423 | 448 | | |
424 | 449 | | |
425 | 450 | | |
| |||
435 | 460 | | |
436 | 461 | | |
437 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
438 | 467 | | |
439 | 468 | | |
440 | 469 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4523 | 4523 | | |
4524 | 4524 | | |
4525 | 4525 | | |
| 4526 | + | |
| 4527 | + | |
4526 | 4528 | | |
4527 | 4529 | | |
4528 | 4530 | | |
| |||
4724 | 4726 | | |
4725 | 4727 | | |
4726 | 4728 | | |
4727 | | - | |
| 4729 | + | |
| 4730 | + | |
4728 | 4731 | | |
4729 | 4732 | | |
4730 | 4733 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
| 712 | + | |
| 713 | + | |
712 | 714 | | |
713 | 715 | | |
714 | 716 | | |
| |||
751 | 753 | | |
752 | 754 | | |
753 | 755 | | |
754 | | - | |
| 756 | + | |
755 | 757 | | |
| 758 | + | |
756 | 759 | | |
757 | 760 | | |
758 | 761 | | |
| |||
0 commit comments