This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Synchronize deletion of mInterface in NSFW destructor #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We're seeing intermittent crashes on Windows calling
mInterface->isWatching()
inStartWorker::Execute
on a background thread. The only unsynchronized access to mInterface that we can find takes place in the destructor of NSFW itself, making us wonder if interleaved calls to start and stop might be causing the following race condition.NSFW
from being garbage collectedHandleOkCallback
runs and clears thepersistent handle, we call start again
NSFW
free to be collected as garbageNSFW
object,which clears the
mInterface
fieldStartWorker
accesses themInterface
pointer on a background thread, which now points to a deleted objectWe don't have proof that this is what is happening, but if it is, I'm hoping that locking the field access in the destructor would prevent it.
I want to do some more local testing on Windows to see if I can reproduce the crash again without this change, then spend 2-3x more time running with this change to see if it avoids the crash. 😓
cc @as-cii @rafeca