Repository navigation
Conversation
…tGenerator NumPy main (numpy/numpy#32332) now builds numpy.random with -DCYTHON_USE_TYPE_SPECS=1, so numpy.random.bit_generator.BitGenerator is a heap type. The dealloc of a heap-type base decrefs the instance's type. The static-type subclasses randomgen builds never took that reference, so every bit generator that is created and destroyed removes one reference from its class. Once the class is freed the interpreter segfaults, which is what the pip-pre Azure job has been hitting since the 2026-11-07 NumPy nightly. Build randomgen's extensions as heap types as well. This is correct for both the heap-type BitGenerator of NumPy main and the static-type BitGenerator of NumPy <= 2.5. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #515 +/- ##
=======================================
Coverage 94.80% 94.80%
=======================================
Files 56 56
Lines 9922 9922
Branches 215 215
=======================================
Hits 9407 9407
Misses 495 495
Partials 20 20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
python312_prerelease(pip-pre) Azure job has segfaulted (exit code 139) since the 2026-11-07 NumPy nightly. The same randomgen commit (51c3967d) passed on 2026-11-05 and crashed on 2026-11-08, so the cause is the NumPy nightly, not randomgen.Cause. numpy/numpy#32332 (PyPy 3.12 support) added
-DCYTHON_USE_TYPE_SPECS=1tonumpy/random/meson.build(see also cython/cython#7947).numpy.random.bit_generator.BitGeneratoris now a heap type. The dealloc of a heap-type base decrefsPy_TYPE(o), but randomgen's subclasses are static types that never took that reference. Every bit generator that is created and destroyed therefore removes one reference from its class. Once the class is freed the interpreter segfaults, and the crash lands in a different test on each run because ofpytest-randomly.Change. Add
-DCYTHON_USE_TYPE_SPECS=1tocython_c_argsso randomgen's extension types are heap types too.tests/meson.builduses the same variable.Verification (local, WSL Ubuntu, Python 3.12, Cython 3.3.1)
numpy 2.6.0.dev0+git20261107.80049a0, the CI test command segfaulted 6 out of 6 runs before the change. With it, 3 out of 3 runs passed: 8764 passed, 148 skipped.sys.getrefcount(cls)changes by 0 over construct/destroy cycles for all 31 bit generator classes. Without the change it drops by 1 per instance for all 31 on the nightly.python310_last_numpy_1job builds on 1.26.4 itself, so CI covers that combination.Caveats
-Dflag, as numpy's own build relies on.continueOnError: true, so a crash there shows as "succeeded with issues" instead of failing the job. Check that step's result, not only the job's overall status.🤖 Generated with Claude Code