Skip to content

BUG: raise ValueError when reading into record array with references (#32227) - #32289

Merged
charris merged 1 commit into
numpy:maintenance/2.5.xfrom
charris:backport-32227
Aug 14, 2026
Merged

BUG: raise ValueError when reading into record array with references (#32227)#32289
charris merged 1 commit into
numpy:maintenance/2.5.xfrom
charris:backport-32227

Conversation

@charris

@charris charris commented Aug 14, 2026

Copy link
Copy Markdown
Member

Backport of #32227.

Fixes a bug with numpy.rec.fromfile and numpy.rec.fromstring where attempting to read into dtypes with references, including object and structured dtypes, would be unsafely accepted and could lead to segfaults. We already guard against this in PyArray_FromFile and related functions:

if (PyDataType_REFCHK(dtype)) {
PyErr_SetString(PyExc_ValueError,
"Cannot read into object array");
Py_DECREF(dtype);
return NULL;
}

The test in this PR would lead to a segfault on main. This bug was reported privately, cc @rgommers

AI Disclosure

I used line completion with GitHub copilot. No other AI used.

@charris charris added this to the 2.5.3 release milestone Aug 14, 2026
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Aug 14, 2026
@charris
charris merged commit 35f20f6 into numpy:maintenance/2.5.x Aug 14, 2026
88 of 90 checks passed
@charris
charris deleted the backport-32227 branch August 14, 2026 21:52
@charris

charris commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

Failed test is unrelated.

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

Labels

00 - Bug 08 - Backport Used to tag backport PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants