Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSelecter test fails on aarch64 #159

Open
saraedum opened this issue Dec 2, 2021 · 0 comments
Open

PSelecter test fails on aarch64 #159

saraedum opened this issue Dec 2, 2021 · 0 comments

Comments

@saraedum
Copy link
Member

saraedum commented Dec 2, 2021

This doctest of PSelecter fails on aarch64 (at least when running with qemu:)

        >>> from cysignals import AlarmInterrupt
        >>> from cysignals.pselect import PSelecter
        >>> import os, signal, time
        >>> with PSelecter([signal.SIGHUP, signal.SIGALRM]) as sel:
        ...     os.kill(os.getpid(), signal.SIGALRM)
        ...     time.sleep(0.5)  # Simply sleep, no interrupt detected
        ...     try:
        ...         _ = sel.sleep(1)  # Interrupt seen here
        ...     except AlarmInterrupt:
        ...         print("Interrupt OK")
        Interrupt OK

Namely, this throws an AlarmInterrupt, I guess before the try block.

The verbose output from a CI run is:

2021-12-02T06:49:33.4949218Z Trying:
2021-12-02T06:49:33.4949643Z     with PSelecter([signal.SIGHUP, signal.SIGALRM]) as sel:
2021-12-02T06:49:33.4950099Z         os.kill(os.getpid(), signal.SIGALRM)
2021-12-02T06:49:33.4950538Z         time.sleep(0.5)  # Simply sleep, no interrupt detected
2021-12-02T06:49:33.4950925Z         try:
2021-12-02T06:49:33.4951310Z             _ = sel.sleep(1)  # Interrupt seen here
2021-12-02T06:49:33.4951710Z         except AlarmInterrupt:
2021-12-02T06:49:33.4952107Z             print("Interrupt OK")
2021-12-02T06:49:33.4952465Z Expecting:
2021-12-02T06:49:33.4952785Z     Interrupt OK
2021-12-02T06:49:34.0024344Z Test src/cysignals/pselect.pyx failed with a <class 'cysignals.signals.AlarmInterrupt'> error: 

The full CI run is here.

This is from a mildly patched cysignals 1.11.0, for packaging for conda-forge, see conda-forge/cysignals-feedstock#35.

The patches applied were:

  • a patch to make cross-compilation work:
 configure.ac | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/configure.ac b/configure.ac
index 2910f9b..07f81a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,9 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[asm("leal (%eax), %eax; emms");]])],
     ,
     dnl NO
     [AC_MSG_RESULT([no])]
+    ,
+    dnl NO, cross compiling.
+    [AC_MSG_RESULT([no])]
 )

 AC_MSG_CHECKING([whether setjmp() saves the signal mask])
@@ -84,6 +87,9 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM(
     ,
     dnl NO
     [AC_MSG_RESULT([no])]
+    ,
+    dnl NO, cross compiling.
+    [AC_MSG_RESULT([no])]
 )

 AC_MSG_CHECKING([for GNU libc])
@@ -132,6 +138,9 @@ AC_RUN_IFELSE([AC_LANG_SOURCE(
     ,
     dnl NO
     [AC_MSG_RESULT([no])]
+    ,
+    dnl NO, cross compiling.
+    [AC_MSG_RESULT([no])]
 )

 dnl Check for atomic operations
  • a patch to ignore some additional output that happens in qemu builds:
--- a/src/cysignals/tests.pyx
+++ b/src/cysignals/tests.pyx
@@ -613,7 +613,7 @@ def unguarded_dereference_null_pointer():
         This probably occurred because a *compiled* module has a bug
         in it and is not properly wrapped with sig_on(), sig_off().
         Python will now terminate.
-        ------------------------------------------------------------------------
+        ...

     The same but with ``CYSIGNALS_CRASH_QUIET`` set. This will crash
     Python silently::
@@ -656,7 +656,7 @@ def unguarded_abort():
         This probably occurred because a *compiled* module has a bug
         in it and is not properly wrapped with sig_on(), sig_off().
         Python will now terminate.
-        ------------------------------------------------------------------------
+        ...

     """
     with nogil:
@@ -691,7 +691,7 @@ def unguarded_stack_overflow():
         This probably occurred because a *compiled* module has a bug
         in it and is not properly wrapped with sig_on(), sig_off().
         Python will now terminate.
-        ------------------------------------------------------------------------
+        ...

     """
     with nogil:
@@ -734,7 +734,7 @@ def test_bad_str(long delay=DEFAULT_DELAY):
         This probably occurred because a *compiled* module has a bug
         in it and is not properly wrapped with sig_on(), sig_off().
         Python will now terminate.
-        ------------------------------------------------------------------------
+        ...

     """
     cdef char* s = <char*>(16)
diff --git a/src/cysignals/tests.pyx b/src/cysignals/tests.pyx
index 0673ffa..6a8156d 100644
--- a/src/cysignals/tests.pyx
+++ b/src/cysignals/tests.pyx
@@ -615,14 +615,6 @@ def unguarded_dereference_null_pointer():
         Python will now terminate.
         ------------------------------------------------------------------------

-    The same but with ``CYSIGNALS_CRASH_QUIET`` set. This will crash
-    Python silently::
-
-        >>> import os
-        >>> env = dict(os.environ)
-        >>> env["CYSIGNALS_CRASH_QUIET"] = ""
-        >>> subpython_err('from cysignals.tests import *; unguarded_dereference_null_pointer()', env=env)
-
     """
     with nogil:
         dereference_null_pointer()
  • a patch to produce more verbose output when testing
--- a/rundoctests.py
+++ b/rundoctests.py
@@ -63,13 +63,15 @@ def testfile(file):
         if sys.platform == 'darwin':
             from cysignals.signals import _setup_alt_stack
             _setup_alt_stack()
-        failures, _ = doctest.testfile(file, module_relative=False,
+        failures, _ = doctest.testfile(file, module_relative=False, verbose=True,
                                        optionflags=flags, parser=parser)
         if not failures:
+            print(f"Test {file} passed.")
             os._exit(0)
     except BaseException as E:
-        print(E)
+        print(f"Test {file} failed with a {type(E)} error: {E}")
     finally:
+        print(f"Test {file} failed.")
         os._exit(23)
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

No branches or pull requests

1 participant