Skip to content

Update to SS:GB 10.5.3 - #163

Open
eriknw wants to merge 11 commits into
GraphBLAS:mainfrom
eriknw:update_10.5.3
Open

eriknw wants to merge 11 commits into
GraphBLAS:mainfrom
eriknw:update_10.5.3

Conversation

@eriknw

@eriknw eriknw commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Update to SuiteSparse:GraphBLAS 10.5.3, along with some fixes my agents recommend.

  • SuiteSparse:GraphBLAS 10.5.3, which fixes a crash when changing a matrix's integer bit-width with pending zombies; the regenerated headers and source.c are unchanged.
  • claim_buffer_2d supports subarray dtypes (also nested ones), with or without spare values; the result is (nrows, ncols) followed by the element axes. Before, column order scrambled the values, and spare values raised after GraphBLAS had handed over the buffer.
  • claim_buffer and claim_buffer_2d free the memory when they raise (it leaked before).
  • give_buffer copies in the array's memory order, so a copy hands GraphBLAS the same bytes as the array itself would.
  • create_headers.py stops when the preprocessor fails (with PyPI's pycparser it wrote empty headers and reported success); AGENTS.md says to use conda-forge's pycparser.
  • Skip test_claim_buffer_frees_on_error on PyPy: its arena allocates with Python cffi callbacks, and on PyPy a cffi callback called from a C extension waits forever for the GIL its own thread holds. The utils module docstring now says an arena's functions must be C functions on PyPy.
  • Build musllinux aarch64 wheels, in a job of their own as for x86_64.
  • cibuildwheel v4.3.5, setup-python v7.1.0, create-pull-request v8.1.3 (supersedes Bump the github-actions group across 1 directory with 3 updates #162); test.yml adds 3.15t and replaces deprecated setup-miniconda options; lint.yml runs pre-commit's steps directly (pre-commit/action uses Node.js 20); pre-commit bumps.

Risk: claim_buffer and claim_buffer_2d now free the buffer when they raise, so a caller that catches the error and still uses or frees the pointer would hit a use-after-free or double free. python-graphblas, the only other user on GitHub, doesn't do that.

- cibuildwheel v4.3.5, setup-python v7.1.0, create-pull-request v8.1.3
- test.yml: add 3.15t now that conda-forge builds numpy, cffi and cython
  for it (coverage there is pure Python, so the existing fallback runs
  the tests without it); replace setup-miniconda's deprecated
  auto-activate-base and nodefaults channel with auto-activate and
  conda-remove-defaults
- lint.yml: run pre-commit's steps directly, since pre-commit/action's
  latest release uses actions/cache@v4, which runs on Node.js 20
- pre-commit: validate-pyproject v0.27, flake8 7.5.0, flake8-bugbear
  26.11.9, zizmor v1.32.0, check-jsonschema 0.39.0
10.5.3 fixes one crash (changing the integer bit-width of a matrix with
pending zombies). The regenerated headers and source.c are unchanged,
and GB_control.h is the same as in 10.5.2, so suitesparse.sh's comment
about which types lack factory kernels still holds.
The preprocessor ran as `gcc ... | sed ... > out` in a shell, whose exit
status is sed's. When gcc failed, the script went on to write empty
headers and source.c and reported success. It does that with pycparser's
PyPI wheels, which leave out the fake libc headers that conda-forge's
pycparser ships.

Run gcc without a shell and fail on its exit status, do the
" complex " -> " _Complex " substitution in Python, and say clearly when
the fake libc headers are missing. With conda-forge's pycparser the
output is byte-identical. AGENTS.md notes which pycparser to use.
With a subarray dtype such as ("<i8", (4,)), NumPy appends the element
axes to the array's shape, and claim_buffer_2d got two cases wrong:
- exact size in column-major order: NPY_ARRAY_F_CONTIGUOUS made the
  element axes the slowest, so values came out scrambled without error;
- spare values: reshaping claim_buffer's result to (nrows, ncols) raised
  ValueError after GraphBLAS had already handed over the buffer.

Give the column-major case explicit strides so the element axes stay
last and contiguous, and keep them last when trimming spare values. The
result is (nrows, ncols) + dtype.shape in every case; exact-size results
still own their data. Built-in dtypes behave as before. New tests cover
built-in and subarray dtypes by row/column order and exact/spare size.
The aarch64 job has skipped musllinux since GraphBLAS#106 (2023-10), when NumPy
had no musllinux aarch64 wheels and that job ran under QEMU.  NumPy has
had them since 1.26.2 (2023-11), and the job runs on a native arm runner
since GraphBLAS#142, so build them in a job of their own, as for x86_64:
CIBW_BEFORE_ALL builds GraphBLAS once per container image, and the musl
build needs its own.
GraphBLAS has handed the memory over by the time it is claimed, so if
claiming raises (an array too big for NumPy, or a buffer smaller than
nrows * ncols), nothing else would free it.  Free it with the arena's
free function instead.  An invalid arena still leaves it alone, since
then there is no free function to use.
GraphBLAS reads the bytes of the buffer it is given, so a copy must hold
them in the order the array has them in memory.  The copy was in C order
unless the array was F-contiguous, which reordered other layouts that
fill their data without gaps, such as the column order claim_buffer_2d
gives a subarray dtype.  Arrays with gaps or a backwards axis are still
copied in C order.
Resizing a matrix to get spare values relied on GraphBLAS keeping the
buffer.  Instead, pack a buffer of exactly the size to test and export
it again, which hands it back unchanged.  Also check that giving the
claimed array back, as itself or as a copy, gives GraphBLAS the layout
it exported.
When the base of a subarray dtype is a subarray dtype too, as with
(("<i2", (3,)), (2,)), NumPy appends its axes after dtype.shape.  With
spare values, claim_buffer_2d reshaped to (nrows, ncols) + dtype.shape,
which left them out: it raised ValueError (the claimed buffer was still
freed) or, for an empty matrix, returned the wrong shape.  Take the
element axes from the claimed array instead.  An exact fit was right
already, since NumPy expands the dtype itself there.
The test's arena allocates and frees with Python cffi callbacks, which
utils.pyx calls directly.  PyPy runs C extension code holding the GIL,
and a cffi callback takes the GIL on entry without checking whether its
own thread holds it, so the first call (from `empty`) waits forever.
PyPy runs extension modules holding the GIL, and a cffi callback takes
the GIL on entry without checking whether its own thread holds it, so a
Python callback that psg or NumPy calls as an arena's function waits
forever.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant