Description
Previous ID | SR-6143 |
Radar | https://bugreport.apple.com/web/?problemID=38213021 |
Original Reporter | rexmas (JIRA User) |
Type | Bug |
Status | Reopened |
Resolution |
Attachment: Download
Environment
iOS 13.x.x
Xcode 11.4
Swift 5
Additional Detail from JIRA
Votes | 6 |
Component/s | Foundation |
Labels | Bug, RunTimeCrash |
Assignee | None |
Priority | Medium |
md5: 315dfe10afb0709dfc204bfedd91b325
Issue Description:
We're getting a random crash, affecting a very significant number of our users. Unfortunately we have not been able to reproduce the crash.
The crash occurs while trying to update a header in our networking stack. We update UUID for the applications session, using an NSUUID. At the point where we read the NSUUID for the session (which is in ObjC) we get an implicit call to
UUID._unconditionallyBridgeFromObjectiveC(_:)
to cast to UUID. This UUID is converted to a string to assign to the header it. This is where it crashes.
We are on Swift 3.2 and the crash only happens on iOS 11.x.x.
The Session object is Optional so the NSUUID that is read and cast is an Optional type, NSUUID?, via optional chaining.
I looked at the source on master https://github.com/apple/swift-corelibs-foundation/blob/f550ea64a4736222b5d32d7a95e1669d31d238b9/Foundation/UUID.swift#L153 and it appears to be implicitly unwrapping an optional type (haven't checked if this is different than swift 3.2). Is it possibly crashing because the value may be nil?
Relevant callstack
Crashed: com.apple.main-thread
EXC_BREAKPOINT 0x0000000106f035f4
0 libswiftFoundation.dylib 0x106f035f4 static UUID._unconditionallyBridgeFromObjectiveC(_:) + 60920
1 Remind101 0x104bb0c38 specialized RDHTTPHeaderable.setSessionUUIDGeneric() -> () (AFHTTPRequestSerializer+Headers.swift:78)
2 Remind101 0x104bb1114 @objc AFHTTPRequestSerializer.setSessionUUID() -> () (AFHTTPRequestSerializer+Headers.swift:131)
3 Remind101 0x1048b7db4 -[RDAPICommunicator setSessionUuid] (RDAPICommunicator.m:121)
4 CoreFoundation 0x18277212c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
5 CoreFoundation 0x1827716cc _CFXRegistrationPost + 420
6 CoreFoundation 0x182771430 ___CFXNotificationPost_block_invoke + 60
7 CoreFoundation 0x1827ee9f4 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1408
8 CoreFoundation 0x1826a83e0 _CFXNotificationPost + 380
9 Foundation 0x1830c8498 -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
10 Remind101 0x1048bf4a4 +[RDSession beginNewSession] (RDSession.m:85)
11 Remind101 0x104977944 -[RDAppDelegate applicationDidBecomeActive:] (RDAppDelegate.m:297)
{{}}