Skip to content

weakrefobject.c doesn't handle allocate_weakref failures #121652

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 Jul 12, 2024 · 0 comments
Closed

weakrefobject.c doesn't handle allocate_weakref failures #121652

colesbury opened this issue Jul 12, 2024 · 0 comments
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@colesbury
Copy link
Contributor

colesbury commented Jul 12, 2024

Bug report

We need to handle the case where allocate_weakref returns NULL due to an out-of-memory error.

PyWeakReference *newref = allocate_weakref(type, obj, callback);
insert_weakref(newref, list);
UNLOCK_WEAKREFS(obj);
return newref;
}
else {
// We may not be able to safely allocate inside the lock
PyWeakReference *newref = allocate_weakref(type, obj, callback);
LOCK_WEAKREFS(obj);
insert_weakref(newref, list);
UNLOCK_WEAKREFS(obj);
return newref;

Linked PRs

@colesbury colesbury added type-bug An unexpected behavior, bug, or error 3.13 bugs and security fixes 3.14 bugs and security fixes labels Jul 12, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Jul 12, 2024
The `allocate_weakref` may return NULL when out of memory. We need to
handle that case and propagate the error.
@Eclips4 Eclips4 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jul 13, 2024
colesbury added a commit that referenced this issue Jul 13, 2024
The `allocate_weakref` may return NULL when out of memory. We need to
handle that case and propagate the error.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 13, 2024
…21653)

The `allocate_weakref` may return NULL when out of memory. We need to
handle that case and propagate the error.
(cherry picked from commit a640a60)

Co-authored-by: Sam Gross <colesbury@gmail.com>
colesbury added a commit that referenced this issue Jul 13, 2024
#121721)

The `allocate_weakref` may return NULL when out of memory. We need to
handle that case and propagate the error.
(cherry picked from commit a640a60)

Co-authored-by: Sam Gross <colesbury@gmail.com>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
)

The `allocate_weakref` may return NULL when out of memory. We need to
handle that case and propagate the error.
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 interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants