Closed lucijan closed 6 years ago
This is a very serious issue. I am looking to redesign Nano::Observer, but it looks like some gauze will need to be applied first. I have verified that the Band-Aid fix you provided has resolved this particular testcase and passes the nano test. Will try to get this up to master soon.
Thankyou for opening this issue.
Matt M.
I stumbled to this issue, too. Used few hours debugging my own code until I found out what @lucijan described above. I implemented similar fix as in band-aid fix and now my application quit crashes are finally gone. Really annoying and serious bug.
If at least two connections with the same
DelegateKey
are added to anObserver
theObserver
will remove the first connection that matches theDelegateKey
. The removed connection under some circumstances doesn't have to be the connection that is intended to remove. Once theObserver
is destructed the dangling pointer will be accessed inObserver::removeAll()
. See the enclosed proof of concept. For our project it was enough to change theObserver::remove
method to take an observer as a second argument and match theDelegateKey
andobserver
.Edit: replaced delete of soruce1 with a call to the deconstructor so that the subsequent call to memset doesn't access free'd memory