-
Notifications
You must be signed in to change notification settings - Fork 298
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
Crash when [CBLRemoteRequest connection:didFailWithError:] #1015
Comments
What version of Couchbase Lite? |
fork from release/1.2 |
The crash log says the crash is in the callback block in The likely culprit here is the reference to |
The point of the weakSelf/strongSelf dance is to avoid a reference cycle, but that means that when the block is called, the receiver may have been dealloced already, so strongSelf will end up nil. In that case, dereferencing it would crash. So check it for nil first. Also fixed some inadvertent references to self in the blocks, which defeat the purpose of using weakSelf. Fixes #1015 (I think; this is a speculative fix)
Fixed on release/1.2 branch. I'm not 100% sure this is what caused your crash, but I'm at least 90% sure. :) |
Thanks! |
The same issue reported by @lucatorella in #1103.
|
The crashing line is [strongSelf removeRemoteRequest:dl]; but the crash is before the call to The block is owned by the CBLMultipartDownloader, and it's called in -[CBLRemoteRequest respondWithResult:error:]: _onCompletion(result, error); So maybe |
If a block ref is stored in an ivar, and the ivar might change due to a re-entrant call during a call to the block, then be safe and copy the block ref to a local variable before calling it. Otherwise the block might be dealloced while its code is running, which will cause garbage results or even crashes when it accesses a captured variable. Fixes #1015
I looked at the disassembly of the call to The fix is to assign the block to a local variable first, then call that. That causes it to be retained until after the call returns. I searched the code for all the places where we call a block in an ivar directly, and fixed the ones where there was a possibility of the block calling back into the calling object. |
Crash comes from Fabric on production version. Trying to reproduce it, but have no idea when this problem happens.
More details about crash:
https://gist.github.com/Magnat12/0260a0c66e0ff4198adb
The text was updated successfully, but these errors were encountered: