diff --git a/src/lib/libexceptions.js b/src/lib/libexceptions.js index 6e402da2f3fc5..5f59c161229c1 100644 --- a/src/lib/libexceptions.js +++ b/src/lib/libexceptions.js @@ -226,6 +226,7 @@ var LibraryExceptions = { var info = new ExceptionInfo(ptr); info.set_rethrown(true); info.set_caught(false); + uncaughtExceptionCount++; #if !DISABLE_EXCEPTION_CATCHING ___cxa_increment_exception_refcount(ptr); exceptionLast = new CppException(ptr); diff --git a/test/core/test_exceptions_uncaught_count.cpp b/test/core/test_exceptions_uncaught_3.cpp similarity index 100% rename from test/core/test_exceptions_uncaught_count.cpp rename to test/core/test_exceptions_uncaught_3.cpp diff --git a/test/core/test_exceptions_uncaught_count.out b/test/core/test_exceptions_uncaught_3.out similarity index 100% rename from test/core/test_exceptions_uncaught_count.out rename to test/core/test_exceptions_uncaught_3.out diff --git a/test/core/test_exceptions_uncaught_4.cpp b/test/core/test_exceptions_uncaught_4.cpp new file mode 100644 index 0000000000000..b59859936fdcd --- /dev/null +++ b/test/core/test_exceptions_uncaught_4.cpp @@ -0,0 +1,27 @@ +#include +#include + +struct DestructorTester { + ~DestructorTester() { + printf("Destructor Uncaught: %d\n", std::uncaught_exceptions()); + } +}; + +int main() { + std::exception_ptr p; + try { + throw std::runtime_error("test"); + } catch (...) { + p = std::current_exception(); + } + + printf("Before Uncaught: %d\n", std::uncaught_exceptions()); + try { + DestructorTester dt; + std::rethrow_exception(p); + } catch (...) { + printf("In catch Uncaught: %d\n", std::uncaught_exceptions()); + } + printf("After Uncaught: %d\n", std::uncaught_exceptions()); + return 0; +} diff --git a/test/core/test_exceptions_uncaught_4.out b/test/core/test_exceptions_uncaught_4.out new file mode 100644 index 0000000000000..ff68d1b2a2815 --- /dev/null +++ b/test/core/test_exceptions_uncaught_4.out @@ -0,0 +1,4 @@ +Before Uncaught: 0 +Destructor Uncaught: 1 +In catch Uncaught: 0 +After Uncaught: 0 diff --git a/test/test_core.py b/test/test_core.py index dfdbdb1eba9ed..5bb1d1bd349a3 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -1457,8 +1457,12 @@ def test_exceptions_rethrow(self): self.do_core_test('test_exceptions_rethrow.cpp') @with_all_eh_sjlj - def test_exceptions_uncaught_count(self): - self.do_core_test('test_exceptions_uncaught_count.cpp') + def test_exceptions_uncaught_3(self): + self.do_core_test('test_exceptions_uncaught_3.cpp') + + @with_all_eh_sjlj + def test_exceptions_uncaught_4(self): + self.do_core_test('test_exceptions_uncaught_4.cpp') @with_all_eh_sjlj def test_exceptions_resume(self):