Commit 081ebf2
authored
[EH] Fix __get_exception_message for multiple inheritance (#24008)
#23552 added a routine to `__get_exception_message` so that in case of a
dependent exception (i.e., a rethrown exception using
`std::rethrow_exception`), it retrieves the correct primary exception's
pointer to call `what()` on. But this turns out not to be correct in all
cases, because `can_catch` can adjust the `thrown_object` pointer here:
https://github.com/emscripten-core/emscripten/blob/ea8eda50e93d28876907bd6576c705478f1c35da/system/lib/libcxxabi/src/cxa_exception_js_utils.cpp#L87-L94
Note that `adjustedPtr` parameter is a reference:
https://github.com/emscripten-core/emscripten/blob/ea8eda50e93d28876907bd6576c705478f1c35da/system/lib/libcxxabi/src/private_typeinfo.h#L25-L26
It appears one of the cases that `thrown_object` pointer can be adjusted
is when the caught exception is of a class that inherits from multiple
classes.
So in case of a dependent exception, if we just retrieve
`reinterpret_cast<__cxa_dependent_exception*>(exception_header)->primaryException`,
we lose the adjustment applied by `can_catch`.
This calls `can_catch` again to make the necessary adjustment again in
case of a dependent exception.
Fixes #23733.1 parent 91c9249 commit 081ebf2
File tree
2 files changed
+38
-1
lines changed- system/lib/libcxxabi/src
- test
2 files changed
+38
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | | - | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9720 | 9720 | | |
9721 | 9721 | | |
9722 | 9722 | | |
| 9723 | + | |
| 9724 | + | |
| 9725 | + | |
| 9726 | + | |
| 9727 | + | |
| 9728 | + | |
| 9729 | + | |
| 9730 | + | |
| 9731 | + | |
| 9732 | + | |
| 9733 | + | |
| 9734 | + | |
| 9735 | + | |
| 9736 | + | |
| 9737 | + | |
| 9738 | + | |
| 9739 | + | |
| 9740 | + | |
| 9741 | + | |
| 9742 | + | |
| 9743 | + | |
| 9744 | + | |
| 9745 | + | |
| 9746 | + | |
| 9747 | + | |
| 9748 | + | |
| 9749 | + | |
| 9750 | + | |
| 9751 | + | |
| 9752 | + | |
| 9753 | + | |
9723 | 9754 | | |
9724 | 9755 | | |
9725 | 9756 | | |
| |||
0 commit comments