Skip to content

BUG: reference leak in simd_sequence_from_iterable - #32038

Merged
seberg merged 1 commit into
numpy:mainfrom
Ethan0456:fix/simd-sequence-from-iterable-oom-leak-main
Jul 19, 2026
Merged

BUG: reference leak in simd_sequence_from_iterable#32038
seberg merged 1 commit into
numpy:mainfrom
Ethan0456:fix/simd-sequence-from-iterable-oom-leak-main

Conversation

@Ethan0456

Copy link
Copy Markdown
Contributor

PR summary

simd_sequence_from_iterable leaked the PySequence_Fast result when simd_sequence_new failed: the min-size path already Py_DECREFd, the OOM path did not. Add the missing Py_DECREF.

No new test; the leak only runs on allocation failure, which we cannot force from Python. Same approach as #31968 (no getrefcount asserts).

No release note (internal leak; no API change).

First time committer introduction

Exploring NumPy and submitting small correctness fixes (e.g. #31968).

AI Disclosure

AI helped locate and draft the fix. Human-reviewed and submitted by a human.

PySequence_Fast returns a new reference that was released
on the min-size error path but not when simd_sequence_new
failed. Drop the Fast ref on allocation failure so OOM does
not leak the sequence.

Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com>
@ngoldbaum ngoldbaum changed the title BUG: DECREF seq_obj on simd_sequence_from_iterable OOM BUG: reference leak in simd_sequence_from_iterable Jul 19, 2026
@ngoldbaum ngoldbaum added the 09 - Backport-Candidate PRs tagged should be backported label Jul 19, 2026

@ngoldbaum ngoldbaum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@seberg
seberg merged commit e0befa7 into numpy:main Jul 19, 2026
92 checks passed
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jul 27, 2026
charris pushed a commit that referenced this pull request Jul 27, 2026
Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com>
charris added a commit that referenced this pull request Jul 27, 2026
BUG: reference leak in `simd_sequence_from_iterable` (#32038)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants