Skip to content

Free threading locking issues in listobject.c #127536

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 Dec 2, 2024 · 5 comments
Closed

Free threading locking issues in listobject.c #127536

colesbury opened this issue Dec 2, 2024 · 5 comments
Assignees
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-free-threading type-bug An unexpected behavior, bug, or error

Comments

@colesbury
Copy link
Contributor

colesbury commented Dec 2, 2024

Bug report

In #127524, @mpage suggested adding an assert to check that the list object is locked when calling ensure_shared_on_resize. This uncovers a few more locking issues.

Additionally, we may return out of the critical section without unlocking here:

Py_BEGIN_CRITICAL_SECTION(a);
Py_ssize_t n = PyList_GET_SIZE(a);
PyObject *copy = list_slice_lock_held(a, 0, n);
if (copy == NULL) {
return -1;
}
ret = list_ass_slice_lock_held(a, ilow, ihigh, copy);
Py_DECREF(copy);
Py_END_CRITICAL_SECTION();

Linked PRs

@colesbury colesbury added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-free-threading labels Dec 2, 2024
@colesbury colesbury changed the title Locking issues in listobject.c Free threading locking issues in listobject.c Dec 2, 2024
@colesbury colesbury added 3.13 bugs and security fixes 3.14 bugs and security fixes labels Dec 2, 2024
@corona10
Copy link
Member

corona10 commented Dec 3, 2024

Ah.. it's my fault, I will take a look at it

@corona10 corona10 self-assigned this Dec 3, 2024
@colesbury
Copy link
Contributor Author

Thanks @corona10. I started some work on this (but didn't finish) yesterday. Here's what I had in case it's helpful:

colesbury@49268ba

@corona10
Copy link
Member

corona10 commented Dec 3, 2024

Ah in that case please go ahead

@corona10 corona10 assigned colesbury and unassigned corona10 Dec 3, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Dec 3, 2024
We were missing locks around some list operations in the free threading
build.
colesbury added a commit that referenced this issue Dec 4, 2024
We were missing locks around some list operations in the free threading
build.
colesbury added a commit to colesbury/cpython that referenced this issue Dec 4, 2024
…27580)

We were missing locks around some list operations in the free threading
build.
(cherry picked from commit e51da64)

Co-authored-by: Sam Gross <[email protected]>
colesbury added a commit that referenced this issue Dec 4, 2024
…27613)

We were missing locks around some list operations in the free threading
build.
(cherry picked from commit e51da64)
@picnixz
Copy link
Member

picnixz commented Dec 5, 2024

@colesbury Are the build bot failures possibly related to that one or not? if not, I think we can close this one.

@colesbury
Copy link
Contributor Author

I think the buildbot failures are unrelated. The other s390x 3.13 buildbots are passing. https://buildbot.python.org/#/builders/1469 is passing, but the runs slowed down (including on test_site) around the same time, but on the following commit, which makes me think some sort of network issue or problem with the machine.

srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this issue Jan 8, 2025
We were missing locks around some list operations in the free threading
build.
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) topic-free-threading type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants