-
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 after receiving 401 error from CBLReplication (ASSERTION FAILED: storage) #805
Comments
Is the backtrace of the crash available? |
Also, could you show the code for the query that generates the crash? I'd like to know whether it's a view or allDocs, whether it's grouped/reduced, etc. Thanks. |
I have a liveQuery and using it as the data source for a tableView, whenever an update happens to the liveQuery, i iterate over the rows, make some filtration if needed and put the rows in an Array and reload the tableView. This is a similar code in
This is the backtrace
|
I'll need to see the code that creates and configures the CBLQuery. Thanks. |
This is all the configurations i make, no group or reduce. CBLView *view = [db viewNamed:@"VIEW_NAME"];
if (!view.mapBlock) {
__weak id weakSelf = self;
[view setMapBlock:^(NSDictionary *doc, CBLMapEmitBlock emit) {
// Emit document if matching criteia
} reduceBlock:nil version:VIEW_VERSION];
}
CBLQuery *query = [view createQuery];
NSSortDescriptor *sd = [NSSortDescriptor sortDescriptorWithKey:@"key" ascending:YES comparator:^NSComparisonResult(NSString *obj1, NSString *obj2) {
BOOL isNumeric1 = [obj1 hasNumericPrefix];
BOOL isNumeric2 = [obj2 hasNumericPrefix];
if (isNumeric1 == isNumeric2) {
return [obj1 compare:obj2 options:NSCaseInsensitiveSearch];
} else if (isNumeric1) {
return NSOrderedDescending;
} else {
return NSOrderedAscending;
}
}];
query.sortDescriptors = @[sd]; |
(Off-topic, but the line __weak id weakSelf = self; right above the map block looks like you're referencing |
Weird … I'm going through the code and I can't see a way this could happen. You're not deleting the view, are you? |
I'm using self only to access a helper method and it does not depend on the state of self, it depends only on the document passed from the map block and it is pure. And sorry, I think the issue is not related to |
Sounds fine, I was just checking because it's a common mistake to reference mutable state in a map function!
Can you give more detail? Particularly, is there a chance the query row is being referenced after the database is deleted? I think that might be able to trigger this crash. |
@pahmed, could you confirm whether the CBLQueryRow was accessed after the database was deleted? If so, I think I understand what's going on and can add a workaround. Otherwise, I'm still stumped. Thanks. |
Yes, and i was also able to reproduce the issue from lldb by adding breakpoint, delete the database then try accessing the value for CBLQueryRow. |
How did you delete the database while the app was stopped at a breakpoint? I can add a fix for the crash, but all it will do is make |
I have a helper method i use to delete the database, and from lldb i'm executing an For the normal cases i do not use CBLQueryRow while the database is deleted, but when i receive |
OK, this won't crash anymore, but CBLQueryRow.value will now return nil if it's called for the first time after the database is deleted. (It caches the value, so if it was called once before the db was deleted it will still return the correct value afterwards.) |
I'm having a crash that happens in my app whenever i receive
401
from the pull replication, it didn't happen in version1.0.3
before i update to1.1
. Here are some logsThe text was updated successfully, but these errors were encountered: