Skip to content

gh-155322: Validate mutable structseq layout attributes - #155361

Open
BHUVANSH855 wants to merge 2 commits into
python:mainfrom
BHUVANSH855:investigate-structseq-n-fields-crash
Open

gh-155322: Validate mutable structseq layout attributes#155361
BHUVANSH855 wants to merge 2 commits into
python:mainfrom
BHUVANSH855:investigate-structseq-n-fields-crash

Conversation

@BHUVANSH855

Copy link
Copy Markdown
Contributor

Summary

Fix a crash in heap-allocated PyStructSequence types when the writable n_fields attribute is modified from Python before constructing a new instance.

The constructor now validates member access using the actual tp_members array instead of relying on the mutable n_fields attribute, preventing out-of-bounds access that could lead to a segmentation fault.

Adds a regression test covering the reported crash.

Closes issue gh-155322.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant