8000 `type_setattro` error return paths contain bugs · Issue #120860 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

type_setattro error return paths contain bugs #120860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
colesbury opened this issue Jun 21, 2024 · 0 comments
Closed

type_setattro error return paths contain bugs #120860

colesbury opened this issue Jun 21, 2024 · 0 comments
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes topic-free-threading type-bug An unexpected behavior, bug, or error

Comments

@colesbury
Copy link
Contributor
colesbury commented Jun 21, 2024

Bug report

The implementation of type_setattro has a few bugs relating to error return paths:

The lock is not released if _PyDict_GetItemRef_Unicode_LockHeld fails:

cpython/Objects/typeobject.c

Lines 5732 to 5736 in 8f17d69

BEGIN_TYPE_DICT_LOCK(dict);
if (_PyDict_GetItemRef_Unicode_LockHeld((PyDictObject *)dict, name, &old_value) < 0) {
return -1;
}

name should be Py_DECREF'd

cpython/Objects/typeobject.c

Lines 5721 to 5723 in 8f17d69

if (dict == NULL) {
return -1;
}

Linked PRs

@colesbury colesbury added type-bug An unexpected behavior, bug, or error 3.13 bugs and security fixes topic-free-threading 3.14 bugs and security fixes labels Jun 21, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Jun 21, 2024
Moves the logic to update the type's dictionary to its own function in order
to make the lock scoping more clear.

Also, ensure that `name` is decref'd on the error path.
colesbury added a commit that referenced this issue Jun 24, 2024
Moves the logic to update the type's dictionary to its own function in order
to make the lock scoping more clear.

Also, ensure that `name` is decref'd on the error path.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 24, 2024
…onGH-120861)

Moves the logic to update the type's dictionary to its own function in order
to make the lock scoping more clear.

Also, ensure that `name` is decref'd on the error path.
(cherry picked from commit dee63cb)

Co-authored-by: Sam Gross <colesbury@gmail.com>
colesbury added a commit that referenced this issue Jun 24, 2024
…120861) (#120963)

Moves the logic to update the type's dictionary to its own function in order
to make the lock scoping more clear.

Also, ensure that `name` is decref'd on the error path.
(cherry picked from commit dee63cb)

Co-authored-by: Sam Gross <colesbury@gmail.com>
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
…on#120861)

Moves the logic to update the type's dictionary to its own function in order
to make the lock scoping more clear.

Also, ensure that `name` is decref'd on the error path.
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
…on#120861)

Moves the logic to update the type's dictionary to its own function in order
to make the lock scoping more clear.

Also, ensure that `name` is decref'd on the error path.
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…on#120861)

Moves the logic to update the type's dictionary to its own function in order
to make the lock scoping more clear.

Also, ensure that `name` is decref'd on the error path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes topic-free-threading type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant
0