Skip to content

[EH] Increment uncaughtExceptionCount in __cxa_rethrow_primary_exception#26527

Merged
aheejin merged 6 commits intoemscripten-core:mainfrom
aheejin:fix_uncaught_rethrow_primary
Mar 24, 2026
Merged

[EH] Increment uncaughtExceptionCount in __cxa_rethrow_primary_exception#26527
aheejin merged 6 commits intoemscripten-core:mainfrom
aheejin:fix_uncaught_rethrow_primary

Conversation

@aheejin
Copy link
Member

@aheejin aheejin commented Mar 24, 2026

This was missing, causing std::uncaught_exceptions() to return incorrect values.

This was missing, causing `std::uncaught_exceptions()` to return
incorrect values.
@aheejin aheejin requested a review from sbc100 March 24, 2026 03:13
@aheejin aheejin changed the title Increment uncaughtExceptionCount in __cxa_rethrow_primary_exception [EH] Increment uncaughtExceptionCount in __cxa_rethrow_primary_exception Mar 24, 2026

struct DestructorTester {
~DestructorTester() {
std::cout << "Destructor Uncaught: " << std::uncaught_exceptions() << "\n";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds strange by can you just use printf here instead of cout ? Using iostreams ends up pulling in a lot of extra library code that isn't needed for the test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: ab28470

self.do_core_test('test_exceptions_rethrow.cpp')

@with_all_eh_sjlj
def test_exceptions_rethrow_primary_uncaught(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the choice of name here? How something like test_uncaught_exceptions_count or test_exceptions_count_uncaught?

Copy link
Member Author

@aheejin aheejin Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is because this is a test case from fixing a bug in __cxa_rethrow_primary_exception and it is printing the uncaught exception count. But yeah the name is not very intuitive. But turns out, we already have test_exceptions_uncaught, test_exceptions_uncaught_2, and test_exceptions_uncaught_count.... How about just renaming the existing test_exceptions_uncaught_count to test_exceptions_uncaught_3, and renaming the new one in this PR to test_exceptions_uncaught_4, to be consistent at least?

Will do that, please tell me if you don't like the names: d7fffa4

@aheejin aheejin merged commit b7dcaab into emscripten-core:main Mar 24, 2026
38 checks passed
@aheejin aheejin deleted the fix_uncaught_rethrow_primary branch March 24, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants