Skip to content

gh-40928: Avoid swallowing AlarmInterrupt in matrix destructor - #42609

Open
cxzhong wants to merge 1 commit into
sagemath:developfrom
cxzhong:agent/fix-linear-code-interrupt-timeout
Open

gh-40928: Avoid swallowing AlarmInterrupt in matrix destructor#42609
cxzhong wants to merge 1 commit into
sagemath:developfrom
cxzhong:agent/fix-linear-code-interrupt-timeout

Conversation

@cxzhong

@cxzhong cxzhong commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #40928.

Root cause

linear_code.py deliberately interrupts a costly canonical-representative
computation after 0.5 seconds. When the alarm arrived while a temporary FLINT
matrix was being destroyed, Matrix_modn_dense_flint.__dealloc__ entered a
sig_on() region. This raised AlarmInterrupt from the destructor, where the
exception could not propagate and was reported as ignored. Because the alarm
was one-shot, the computation then continued until the doctest file timeout.

This follows #18087, which established that __dealloc__ methods cannot raise
exceptions and therefore must not enter sig_on() regions.

Changes

  • Do not wrap nmod_mat_clear() in sig_on()/sig_off() during destruction.
  • Initialize _shift_mod's preshift temporary explicitly, eliminating the
    compiler's -Wmaybe-uninitialized warning.

Validation

  • Rebuilt matrix_modn_dense_flint successfully; the compiler warning is gone.
  • src/sage/matrix/matrix_modn_dense_flint.pyx: 175 doctests passed.
  • src/sage/coding/linear_code.py: 424 doctests passed.
  • Repeated the linear-code doctests with all four random seeds from recent CI
    timeouts; all passed.

Local validation used Linux with Python 3.12; CI will additionally exercise the
macOS/Python 3.14 configuration where this occurred frequently.

@cxzhong cxzhong added the p: CI fix merged before running CI tests label Aug 1, 2026
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

Documentation preview for this PR (built with commit fe1e853; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@vincentmacri

Copy link
Copy Markdown
Member

Test failure is real but is unrelated as it occurs on develop. Reported in #42623.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: CI fix merged before running CI tests s: positive review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linear_code test timeout

2 participants