Skip to content

Fix data race in NNDescent::update()#5413

Open
RohanMali2003 wants to merge 5 commits into
facebookresearch:mainfrom
RohanMali2003:fix/nndescent-data-race
Open

Fix data race in NNDescent::update()#5413
RohanMali2003 wants to merge 5 commits into
facebookresearch:mainfrom
RohanMali2003:fix/nndescent-data-race

Conversation

@RohanMali2003

Copy link
Copy Markdown

other.pool.back() was read before acquiring other.lock, racing with concurrent pop_heap and push_heap calls in Nhood::insert(). Moved the lock acquisition before the read in both rnn_new and rnn_old branches. Fixes issue #5276.

I was not able to build the project locally, so this change has not been compiled or run through the test suite. The fix mirrors the reordering proposed in the linked issue exactly, as proposed by reporter @wonder-fly : moving LockGuard guard(other.lock) before the other.pool.back() read in both the rnn_new and rnn_old branches. Happy to iterate based on CI results or review feedback. Thanks!

other.pool.back() was read before acquiring other.lock, racing with concurrent pop_heap and push_heap calls in Nhood::insert(). Move the lock acquisition before the read in both rnn_new and rnn_old branches. Fixes issue facebookresearch#5276.
@meta-cla meta-cla Bot added the CLA Signed label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant