Skip to content

Check that values hold whole elements before building from them - #642

Open
eriknw wants to merge 2 commits into
47a-take-ownership-allocatorfrom
47b-udt-values-length
Open

eriknw wants to merge 2 commits into
47a-take-ownership-allocatorfrom
47b-udt-values-length

Conversation

@eriknw

@eriknw eriknw commented Oct 19, 2026

Copy link
Copy Markdown
Member

Values for a sub-array dtype are converted to its scalar type, and build
counted only the leading dimension, so

Vector.from_coo([0, 1], np.ones(2), "FP64[2]")

handed GraphBLAS 2 numbers where it reads 4 and built from whatever memory
followed the array: the second element came back as garbage (3.1e-314 in one
run), and under macOS guard malloc the process segfaults. It now raises

ValueError: values must have shape (2, 2) for dtype FP64[2], not (2,)

in build, from_csr/from_csc and from_dense. Two scalar cases in the same code
are fixed too: on suitesparse-vanilla a scalar value now fills whole elements
(it read past the end the same way), and on SuiteSparse from_csr/from_csc with
a scalar no longer raise InvalidValue for a sub-array dtype. Record UDTs were
not affected. The new tests fail without the fix. A second commit skips
them on suitesparse-vanilla without numba, where a UDT cannot be built.

The ss.import_* functions could over-read the same way (UDT values, and
built-in values when nvals or size is given); the next PR guards them.

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.64%. Comparing base (4d473ee) to head (8a00ef4).

Additional details and impacted files
@@                       Coverage Diff                        @@
##           47a-take-ownership-allocator     #642      +/-   ##
================================================================
- Coverage                         98.66%   98.64%   -0.03%     
================================================================
  Files                               105      105              
  Lines                             29389    29443      +54     
  Branches                           3446     3449       +3     
================================================================
+ Hits                              28997    29043      +46     
- Misses                              257      261       +4     
- Partials                            135      139       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eriknw
eriknw added this pull request to stack #650 October 19, 2026 07:50
@eriknw
eriknw force-pushed the 47b-udt-values-length branch 2 times, most recently from 72b5b5d to d78b619 Compare October 20, 2026 22:28
@eriknw
eriknw force-pushed the 47b-udt-values-length branch from d78b619 to 9d1970f Compare October 21, 2026 04:14
@eriknw
eriknw force-pushed the 47b-udt-values-length branch from 9d1970f to 3495a38 Compare October 21, 2026 08:38
@eriknw
eriknw removed this pull request from stack #650 October 28, 2026 04:29
@eriknw
eriknw force-pushed the 47b-udt-values-length branch from 3495a38 to 310edf5 Compare October 28, 2026 04:29
@eriknw
eriknw added this pull request to stack #653 October 28, 2026 04:30
@eriknw
eriknw removed this pull request from stack #653 October 28, 2026 04:31
@eriknw
eriknw added this pull request to stack #655 October 28, 2026 04:32
@eriknw
eriknw removed this pull request from stack #655 October 28, 2026 04:33
@eriknw
eriknw added this pull request to stack #657 October 28, 2026 04:33
@eriknw
eriknw force-pushed the 47b-udt-values-length branch from 310edf5 to d9e3728 Compare October 28, 2026 13:21
Values for a sub-array dtype are converted to its scalar type, and build
counted only the leading dimension, so `Vector.from_coo([0, 1], np.ones(2),
"FP64[2]")` handed GraphBLAS 2 numbers where it reads 4 and built from
whatever followed the array. Raise unless the trailing shape is the
element's, in build, from_csr/from_csc, and from_dense. Without SuiteSparse,
a scalar value now broadcasts to whole elements too (it read past the end
the same way), and from_csr/from_csc with a scalar no longer fail for a
sub-array dtype on SuiteSparse.
Without SuiteSparse, build gives a UDT the dup_op binary.any, and that
needs Numba, so test_subarray_dtype_values_shape failed with a KeyError
on the vanilla backend without Numba. Skip it there only; without Numba
on SuiteSparse it still runs.
@eriknw
eriknw force-pushed the 47b-udt-values-length branch from d9e3728 to 8a00ef4 Compare October 29, 2026 02:01
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