Skip to content

Commit b2392aa

Browse files
author
Release Manager
committed
gh-40613: Fix Ctrl-C segfaults in sage.libs.gap Replace cysignals' `sig_on()` and `sig_off()` with custom `gap_sig_on()` and `gap_sig_off()` wrappers that use GAP's own `SIGINT` handling. This fixes an uncommon, but ultimately reproducible segfault when Ctrl-C is used to interrupt a GAP computation. In concert with #40594 this has allowed `sage/libs/gap/element.pyx` to pass many thousands of test iterations. ### Fixes * #40598 ### Dependencies * #40594 URL: #40613 Reported by: Michael Orlitzky Reviewer(s): Dima Pasechnik, Michael Orlitzky, user202729
2 parents decf49d + c1adeb9 commit b2392aa

File tree

7 files changed

+350
-112
lines changed

7 files changed

+350
-112
lines changed

src/sage/doctest/util.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,16 @@ def ensure_interruptible_after(seconds: float, max_wait_after_interrupt: float =
883883

884884
try:
885885
yield data
886-
except AlarmInterrupt as e:
887-
e.__traceback__ = None # workaround for https://github.com/python/cpython/pull/129276
888-
alarm_raised = True
886+
except KeyboardInterrupt as e:
887+
# AlarmInterrupt is a subclass of KeyboardInterrupt, so this
888+
# catches both. The "user interrupt" message is a quirk of
889+
# GAP interrupts that result from SIGALRM.
890+
if isinstance(e, AlarmInterrupt) or "user interrupt" in str(e):
891+
# workaround for https://github.com/python/cpython/pull/129276
892+
e.__traceback__ = None
893+
alarm_raised = True
894+
else:
895+
raise
889896
finally:
890897
before_cancel_alarm_elapsed = walltime() - start_time
891898
cancel_alarm()

0 commit comments

Comments
 (0)