-
Notifications
You must be signed in to change notification settings - Fork 1.6k
EXC_BAD_ACCESS (SIGSEGV) with Storage and Carthage #3750
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
Comments
Thanks for the fast response @paulb777 . Seen the file/method, but haven't spent much time digging into it. Am I missing something obvious? |
@supermarin I don't see anything on quick glance, but wanted to leave a pointer for anyone who wants to go deeper, since I'm not able to investigate now. The crash should be debuggable in a CocoaPods installation. It's likely something exposed/triggered by the Xcode 11 beta, since this code is relatively stable. |
Just tried with Xcode 10.3, same issue.
If I catch time I'll try to debug with CocoaPods. |
A full sample would help us to investigate. |
@paulb777 can provide tonight when I get home |
The problem is here, where you call a stored block on a nullable reference without checking if it's still alive. This fixes the problem: [strongSelf->_uploadFetcher
beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
if (weakSelf) {
weakSelf.fetcherCompletion(data, error);
}
}]; Another issue is that this gets called more than once per task completion, and I haven't had time to drill that one down. If you add logs to both cases, you can observe that the completion block sometimes gets called more than once, when the task dies. [strongSelf->_uploadFetcher
beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
if (weakSelf) {
NSLog(@"Was not null!");
weakSelf.fetcherCompletion(data, error);
} else {
NSLog(@"Was null!");
}
}];
|
@supermarin I'm not completely following. If It does seem like a problem for the completion block to be called twice. |
The problem is not with calling methods on a niled out __weak ref, but invoking a block reference that's now a NULL pointer. You can reproduce it quite easily: #import <Foundation/Foundation.h>
@interface Task: NSObject
@property (nonatomic, copy) bool(^completion)();
@property (nonatomic, strong) NSString *doesntBlowUp;
- (void)doSomething;
@end
@implementation Task
- (void)doSomething {}
@end
Task *createTask() {
return [Task new];
}
int main(int argc, char * argv[]) {
__weak Task *task = createTask();
task.doesntBlowUp = @"nop";
task.completion = ^bool() {
return false;
};
NSLog(@"just a proof that the block doesn't crash");
task.completion();
task = nil;
NSLog(@"property access is OK: %@", task.doesntBlowUp);
NSLog(@"method access is safe too.");
[task doSomething];
NSLog(@"invoking a NULL pointer will crash");
task.completion();
return 1;
} Outputs:
|
Thanks for the explanation! That makes sense. I'm not able to reproduce the double call problem. I'm also not able to reproduce the crash, but I can see how in theory it could happen. I'm testing a fix at #3786. |
Thanks Paul, I can try it at home later tonight and let you know if it fixed the issue. |
@paulb777 fix works, and the second completion doesn't get called anymore because of the nil check (it still hits your code occasionally though). In any case it's better than what's currently released in 6.7.0. If you wouldn't mind releasing 6.7.1 after merging, that'd be highly appreciated. |
@supermarin Thanks for testing. The fix is now merged. I assume that pushing out a CocoaPods FirebaseStorage update doesn't help you? Our Carthage publishing script is a little rough and in transition, but we can look at getting a 6.8.1 out next week. (6.8.0 released yesterday) |
Yep CocoaPods won't help, please do it in 6.8.1 if you can. Thanks a bunch |
We released 6.8.1 to CocoaPods today. The Carthage distro should go out tomorrow. In the meantime, the fixed FirebaseStorage.framework is available in the zip distro. |
Carthage 6.8.1 is out. |
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Upon completion of uploadTasks, in about 1/3 of cases the app crashes with EXC_BAD_ACCESS (SIGSEGV)
Steps to reproduce:
NOTE: it doesn't crash on every single upload, crashes about 1/3 of the time.
Relevant Code:
Gist with full crash log: https://gist.github.com/supermarin/b9fe575cd95efeb905e3b771f0fd883c
The text was updated successfully, but these errors were encountered: