-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Fix data race in PagedArray #86412
Fix data race in PagedArray #86412
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good besides the little nitpick.
Looks good! Could you squash the commits? See PR workflow for instructions. |
67f7c6c
to
70bfd5d
Compare
@RandomShaper squashed |
Thanks! And congrats for your first merged Godot contribution 🎉 -- hopefully the start of many, given what I know you've been cooking ;) |
Cherry-picked for 4.2.2. |
This PR resolves a data race in the
PagedArrayPool
andPagedArray
types. The thread sanitiser identified the data race via thepage_pool
field of thePagedArrayPool
class. The write occurred:godot/core/templates/paged_array.h
Line 62 in 9d1cbab
and the concurrent read here:
godot/core/templates/paged_array.h
Line 78 in 9d1cbab
The actual data race of the
page_pool
pointer being access concurrently is possibly safe, as it is a word read / write, however, an additional problem is the underlying memory in thememrealloc
from the old allocation is being immediately zero'd in debug builds on macOS, so the call theget_page
is sometimes returning annullptr
. In a release build, the old allocation may be immediately reused before the call toget_page
, returning an invalid pointer, resulting in crashes, memory corruption, etc.