[EH] Fix __get_exception_message for multiple virtual inheritance#26946
Merged
Conversation
This fixes `__get_exception_message` so it works with multiple virtual inheritance. emscripten-core#24008 tried to fix this, but the test case there didn't `virtual` in the line where the inheritance happens. In case of dependent exceptions (= the exceptions thrown by `std::rethrow_exception`), we should not even dereference `thrown_object`, because it doesn't contain anything. emscripten-core#24008 ran `can_catch` on the currect primary exception but before that it called `can_catch` on the dependent exception first, which caused the memory error. emscripten-core#24008's test case was fine because it didn't have `virtual`, we didn't have to dereference `thrown_object` (`adjustedPtr` in this method) directly: https://github.com/emscripten-core/emscripten/blob/b2e19a341ac53b33de3aae7b4ea7bf7168ebace7/system/lib/libcxxabi/src/private_typeinfo.cpp#L572-L579 This computes the primary exception pointer first and then call `can_catch`. Fixes emscripten-core#26771.
sbc100
approved these changes
May 14, 2026
Collaborator
sbc100
left a comment
There was a problem hiding this comment.
Do we really need test_multi_inheritance_exception_message and test_multi_inheritance_exception_message2 both? Or can we adapt the first one maybe?
Otherwise lgtm
Member
Author
|
We can probably just delete the first one I think. Multiple inheritance seems almost always paired with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes
__get_exception_messageso it works with multiple virtual inheritance. #24008 tried to fix this, but the test case there didn'tvirtualin the line where the inheritance happens.In case of dependent exceptions (= the exceptions thrown by
std::rethrow_exception), we should not even dereferencethrown_object, because it doesn't contain anything. #24008 rancan_catchon the currect primary exception but before that it calledcan_catchon the dependent exception first, which caused the memory error. #24008's test case was fine because it didn't havevirtual, we didn't have to dereferencethrown_object(adjustedPtrin this method) directly:emscripten/system/lib/libcxxabi/src/private_typeinfo.cpp
Lines 572 to 579 in b2e19a3
This computes the primary exception pointer first and then call
can_catch.Fixes #26771.