8000 gh-111926: Make weakrefs thread-safe in free-threaded builds by mpage · Pull Request #117168 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-111926: Make weakrefs thread-safe in free-threaded builds #117168

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

Merged
merged 67 commits into from
Apr 8, 2024
Merged
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
9bf3820
Add _PyObject_SetMaybeWeakref
mpage Mar 14, 2024
75603c1
Make PyWeakref_NewRef thread-safe
mpage Mar 15, 2024
c4f8453
Make PyWeakref_NewProxy thread-safe
mpage Mar 15, 2024
ece230f
Make weakref___new___ thread-safe
mpage Mar 15, 2024
9acae59
Make weakref_hash thread-safe
mpage Mar 15, 2024
6d00f51
Make _PyStaticType_ClearWeakRefs thread-safe
mpage Mar 15, 2024
363a1a6
Handle multiple weakrefs
mpage Mar 15, 2024
c9b3bf9
Make _PyWeakref_GetWeakrefCount thread-safe
mpage Mar 16, 2024
b7b3315
Make _weakref._getweakrefs thread-safe
mpage Mar 16, 2024
e6e2d28
Make weakref clearing in subtype_dealloc thread-safe
mpage Mar 16, 2024
0d259d1
Fix incorrect size in test_sys for weakref/proxy
mpage Mar 16, 2024
7cc523b
Use a once flag
mpage Mar 18, 2024
11be247
Simplify clearing callback-free refs
mpage Mar 18, 2024
8fcd33f
Rationalize naming
mpage Mar 18, 2024
1e1e609
Fix warning
mpage Mar 18, 2024
19a274e
Simplify ClearWeakRefs
mpage Mar 19, 2024
817a5a3
Refactor clearing code
mpage Mar 19, 2024
d493e7d
Protect wr_object with a separate mutex
mpage Mar 20, 2024
88078a6
Switch to a sharded lock for linked list and object
mpage Mar 21, 2024
dc1f651
Fix formatting
mpage Mar 22, 2024
37c511a
Remove vestigial include
mpage Mar 22, 2024
ccaeded
Make sure we set the cleared flag
mpage Mar 22, 2024
6a50381
Use `Py_TryIncref` when returning the ref
mpage Mar 23, 2024
d998d1b
Don't leak ref if initialization fails
mpage Mar 24, 2024
37076b5
Remove clinic critical section directives for `_weakref` module
mpage Mar 24, 2024
a07d2db
Support async removal of dead weakrefs from WeakValueDictionary
mpage Mar 24, 2024
a901848
Only use the striped lock
mpage Mar 26, 2024
8c85fd3
Refactor weakref creation
mpage Mar 27, 2024
0021bc5
Fixups
mpage Mar 27, 2024
40d99d4
Fix formatting
mpage Mar 27, 2024
dd922b1
Use QSBR to avoid locking in PyType_IsSubtype
mpage Mar 26, 2024
681872e
Remove unnecessary include
mpage Mar 27, 2024
8982831
Fix unused function warning in default builds
mpage Mar 27, 2024
334c766
Check for callable proxy
mpage Mar 28, 2024
0549445
Refactor weakref creation
mpage Mar 29, 2024
eb12c06
Simplify comment
mpage Mar 29, 2024
700cf4c
Get rid of GetWeakrefCountThreadsafe
mpage Mar 29, 2024
63200cd
Don't explicitly zero initialize striped lock
mpage Mar 29, 2024
e9eed72
Indent conditional define
mpage Mar 29, 2024
e3d5779
Use non-atomic loads while we hold the lock
mpage Mar 29, 2024
f31f1e5
Refactor a _PyWeakref_GET_REF and _PyWeakref_IS_DEAD to share more code
mpage Mar 29, 2024
b5c9561
Merge helper functions for clearing weakrefs
mpage Mar 29, 2024
93425e6
Make _PyStaticType_ClearWeakRefs have one implementation for default …
mpage Mar 29, 2024
89edf02
Make sure we're able to index into the striped lock even if GC clears us
mpage Mar 29, 2024
7f73480
Consolidate implementations of _PyWeakref_ClearRef and gc_clear
mpage Mar 29, 2024
d742ed1
Rename `_Py_TryIncref` to `_Py_TryIncrefCompare`
mpage Mar 29, 2024
37f9ceb
Add `_Py_TryIncref`
mpage Mar 29, 2024
fb9eee5
Refactor `weakref._getweakrefs` to have one implementation
mpage Mar 29, 2024
d760b99
Refactor to have one implementation for `PyObject_ClearWeakRefs`
mpage Mar 29, 2024
491e4ff
Revert "Use QSBR to avoid locking in PyType_IsSubtype"
mpage Mar 29, 2024
531a076
Accept thread unsafety when checking subtype for now
mpage Mar 29, 2024
ed280d8
Update modules to use PyWeakref_GetRef
mpage Mar 29, 2024
2750787
Merge branch 'main' into gh-111926-thread-safe-weakref
mpage Mar 29, 2024
5e7c8bb
Use a pointer to the appropriate mutex rather than a copy of the obje…
mpage Mar 29, 2024
37c9529
Fix formatting
mpage Mar 29, 2024
fece88d
Merge implementation of try_reuse_basic_ref
mpage Mar 29, 2024
7a86e35
Remove redundant gc untrack
mpage Apr 2, 2024
f89edd1
Update comment
mpage Apr 2, 2024
5a0b976
Add missing braces
mpage Apr 2, 2024
9e67740
Use Py_ssize_t for tracking number of items
mpage Apr 2, 2024
55a211f
Tighten up clearing basic refs/proxies
mpage Apr 2, 2024
cdb9290
Simplify _PyStaticType_ClearWeakRefs
mpage Apr 2, 2024
c93c336
Simplify get_or_create_weakref
mpage Apr 2, 2024
0366f01
Add _PyWeakref_IsDead
mpage Apr 2, 2024
3e135e4 8000
Remove TODO
mpage Apr 2, 2024
dbf7c58
Fix formatting
mpage Apr 2, 2024
73466bf
Update Python/pystate.c
colesbury Apr 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor weakref creation
  • Loading branch information
mpage committed Mar 27, 2024
commit 8c85fd389194c3b54801c6be205aa7b9ad8ef6f6
Loading
0