We have encountered a crash in MAS library (using build 2.2 for iOS) due to array mutating while being enumerated:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 19
Application Specific Information:
abort() called
Last Exception Backtrace:
0 CoreFoundation 0x187e44cb4 __exceptionPreprocess + 164
1 libobjc.A.dylib 0x180eec3d0 objc_exception_throw + 60
2 CoreFoundation 0x187fb1920 -[__NSSingleObjectEnumerator init] + 0
3 MASFoundation 0x10186cb10 -[MASURLSessionManager taskOperationWithTask:] + 160
4 MASFoundation 0x10186cd5c -[MASURLSessionManager removeSessionTaskFromOperations:] + 20
5 MASFoundation 0x10186cf34 -[MASURLSessionManager URLSession:task:didCompleteWithError:] + 140
As a hotfix, we could do this update on MASURLSessionManager.m:
- (MASSessionTaskOperation *)taskOperationWithTask:(NSURLSessionTask *)task
{
MASSessionTaskOperation *taskOperation = nil;
for (MASSessionTaskOperation *operation in [self.operations copy])
{
if ([operation.task isEqual:task])
{
taskOperation = operation;
}
}
return taskOperation;
}
- (MASSessionDataTaskOperation *)dataTaskOperationWithDataTask:(NSURLSessionDataTask *)dataTask
{
MASSessionDataTaskOperation *dataTaskOperation = nil;
for (MASSessionDataTaskOperation *operation in [self.operations copy])
{
if ([operation.task isEqual:dataTask])
{
dataTaskOperation = operation;
}
}
return dataTaskOperation;
}
Issue Description:
Failing scenarios:
If it is searching for taskoperation t3 in array [t1, t2, t3 ] and t3 got removed during the iteration, then currently it is returning t2 instead of t3 . What is the expected behavior. Should it return nil ? Currently it is returning t2 which, looks like incorrect.
Release : 4.2
Code bug.
The issue has been resolved by a fix. Request the patch through the support.