Open ashione opened 1 year ago
I found it fix invalid iterator issue but there is another deadlock condition:
Hi @ashione, thanks for collaborating! I think this can generate a deadlock as you mentioned, let me check it a little bit. Maybe we can get the iterator end inside the lock, something like:
bool foundIt = false;
{
Lock lock( mWatchesLock );
wit = mWatches.find( pevent->wd );
foundIt = wit != mWatches.end();
}
if ( foundIt ) {
Hi @ashione, thanks for collaborating! I think this can generate a deadlock as you mentioned, let me check it a little bit. Maybe we can get the iterator end inside the lock, something like:
bool foundIt = false; { Lock lock( mWatchesLock ); wit = mWatches.find( pevent->wd ); foundIt = wit != mWatches.end(); } if ( foundIt ) {
Actually, we use this data in handleAction
after iterator located but related inotify pointer had been deleted.
How to avoid accessing invalid iterator out of thie scope lock domain?
iterator
wit
might be an invalid if this iterator has been removed from map collection afterfind
method.