BUG: avoid segmentation fault in string_expandtabs_length_promoter by charris · Pull Request #29920 · numpy/numpy

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@charris

Copy link

Member

@charris charris commented

Oct 10, 2025

Backport of #29368.

Fix to use Py_XINCREF instead of Py_INCREF to safely handle the case where op_dtypes[0] is NULL

Root Cause

  • When calling string_expandtabs_length_promoter, the first item of op_dtypes can be NULL.

Rationale

  • As noted in this comment regarding ops, legacy type resolution does not handle NULL well. Therefore, I changed the logic to use the second item instead.

Outcome

  • numpy._core.strings._expandtabs_length.reduce(numpy.zeros(200)) now raises a UFuncTypeError, instead of causing a segmentation fault.

@charris charris added this to the 2.3.4 release milestone

Oct 10, 2025

@charris charris added 00 - Bug 08 - Backport

Used to tag backport PRs

labels

Oct 10, 2025
…gth.reduce`

Fixes the first item of numpy#28829. Use `Py_XINCREF` instead of `Py_INCREF` to safely handle the case where `op_dtypes[0]` is NULL

@charris charris merged commit 4491392 into numpy:maintenance/2.3.x

Oct 10, 2025

74 checks passed

@charris charris deleted the backport-29368 branch

October 10, 2025 17:38

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

Reviewers

No reviews

Assignees

No one assigned

Labels

00 - Bug 08 - Backport

Used to tag backport PRs

Projects

None yet

Milestone

2.3.4 release

Development

Successfully merging this pull request may close these issues.

2 participants

@charris @riku-sakamoto