python-greenlet / greenlet

Lightweight in-process concurrent programming
Other
1.63k stars 247 forks source link

C++ exception test fails in 3.0.1 on arm-linux-gnueabihf #385

Closed doko42 closed 9 months ago

doko42 commented 10 months ago

As seen in https://launchpad.net/ubuntu/+source/python-greenlet/3.0.1-0ubuntu1/+build/26969609 the test fails on arm-linux-gnueabihf, but succeeds on other architectures.

this fails with both 3.11 and 3.12.

====================================================================== FAIL: test_unhandled_std_exception_as_greenlet_function_aborts (greenlet.tests.test_cpp.CPPTests.test_unhandled_std_exception_as_greenlet_function_aborts)

Traceback (most recent call last): File "/<>/.pybuild/cpython3_3.12/build/greenlet/tests/leakcheck.py", line 316, in wrapper return _RefCountChecker(self, method)(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/<>/.pybuild/cpython3_3.12/build/greenlet/tests/leakcheck.py", line 294, in call self._run_test(args, kwargs) File "/<>/.pybuild/cpython3_3.12/build/greenlet/tests/leakcheck.py", line 212, in _run_test self.function(self.testcase, *args, **kwargs) File "/<>/.pybuild/cpython3_3.12/build/greenlet/tests/test_cpp.py", line 58, in test_unhandled_std_exception_as_greenlet_function_aborts self.assertIn( AssertionError: 'greenlet: Unhandled C++ exception: Thrown from an extension.' not found in "fail_cpp_exception is running\nraising <built-in method switch of greenlet.greenlet object at 0xf7b3e748>\nterminate called after throwing an instance of 'std::runtime_error'\n what(): Thrown from an extension.\n"


Ran 137 tests in 28.518s

FAILED (failures=1, skipped=1)

jamadden commented 10 months ago

We run linux arm tests as part of CI, so it appears that the libc/libc++ runtime on this platform is different than that of the manylinux2014_aarch64 images (or indeed, any of the manylinux images for any platform, or the standard github Ubuntu images).

The code appears to be functioning correctly, only the error message is different from the expected value.

Patches welcome; it should just be a small tweak to the test. However, because we don't have CI for this platform I can't guarantee things won't break again.

doko42 commented 10 months ago

there's a misunderstanding. This is ARM32, not AArch64.

this is the current Ubuntu development version, leading to 24.04 LTS. It has glibc 2.37, and libstdc++ from GCC 13.2

jamadden commented 10 months ago

Nonetheless, what I said stands. Patches welcome.

LocutusOfBorg commented 9 months ago
--- python-greenlet-3.0.1.orig/src/greenlet/tests/test_cpp.py
+++ python-greenlet-3.0.1/src/greenlet/tests/test_cpp.py
@@ -56,7 +56,7 @@ class CPPTests(TestCase):
         # verify that plain unhandled throw aborts
         output = self._do_test_unhandled_exception('run_as_greenlet_target')
         self.assertIn(
-            'greenlet: Unhandled C++ exception: Thrown from an extension.',
+            'Thrown from an extension.',
             output
         )

Is something like this accepted?

jamessan commented 9 months ago

AssertionError: 'greenlet: Unhandled C++ exception: Thrown from an extension.' not found in "fail_cpp_exception is running\nraising <built-in method switch of greenlet.greenlet object at 0xf7b3e748>\nterminate called after throwing an instance of 'std::runtime_error'\n what(): Thrown from an extension.\n"

Based on the message that does come out, it seems like an exception is being thrown from the exception handling here, causing terminate. Maybe that should be investigated, @LocutusOfBorg, rather than making the expected message more generic.

jamadden commented 9 months ago

@jamessan terminate is the expected behaviour and is what is being tested here. Only the error message differs. @LocutusOfBorg Yes, that's perfectly fine. I have a few minutes to work on this today and will make that change.

matoro commented 9 months ago

For reference, this affects sparc64 also, and the patch fixes it in the same way.