Skip to content

[mypyc] Fix crash and reference leaks on base resolution failures - #22244

Merged
p-sawicki merged 2 commits into
python:masterfrom
p-sawicki:misc_ops-base-resolution-failure-cleanup
Oct 21, 2026
Merged

p-sawicki merged 2 commits into
python:masterfrom
p-sawicki:misc_ops-base-resolution-failure-cleanup

Conversation

@p-sawicki

Copy link
Copy Markdown
Collaborator

update_bases returns NULL on error but the result was not checked so the null pointer could be passed to a function that doesn't expect it and crash.

Add a null check and missing decrefs in update_bases on failures.

When creating a type object from a template, the tp_doc pointer was allocated twice, so keep just one allocation.

Comment thread mypyc/test-data/run-classes.test Outdated
assert read_numbers(child, 100) == 300.0


[case testNativeClassDocAfterFailedConstruction]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you merge these into an existing [case ...] since each run test has a substantial per-test case overhead? Possible rename a test if you can't find an existing one that would cover these test cases cleanly.

@p-sawicki
p-sawicki merged commit 972be3a into python:master Oct 21, 2026
18 checks passed
@p-sawicki
p-sawicki deleted the misc_ops-base-resolution-failure-cleanup branch October 21, 2026 13:07
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.

2 participants