Apollo-ios: Crash in Alamofire

Created on 13 Oct 2020  路  6Comments  路  Source: apollographql/apollo-ios

Bug report

Since upgrading to the latest 0.34.0 release line with the revamped networking stack, we are seeing intermittent failures in conjunction with Alamofire. Is this a known issue?

Code Type:             X86-64 (Native)
Parent Process:        launchd_sim [2352]
Responsible:           SimulatorTrampoline [2256]
User ID:               501

Date/Time:             2020-10-13 14:15:09.012 +0000
OS Version:            Mac OS X 10.15.5 (19F101)
Report Version:        12
Anonymous UUID:        4763FA26-E06C-409D-9FAC-0174438B0AC7


Time Awake Since Boot: 2500 seconds

System Integrity Protection: disabled

Crashed Thread:        7  Dispatch queue: org.alamofire.session.rootQueue

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x000027b7a55693a0
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [6910]

VM Regions Near 0x27b7a55693a0:
    mapped file            000000011638b000-000000011caba000 [103.2M] r--/rwx SM=COW  Object_id=254d583f
--> 
    MALLOC_NANO            0000600000000000-0000600008000000 [128.0M] rw-/rwx SM=ALI  

Application Specific Information:
CoreSimulator 704.12.2 - Device: iPhone 11 (********-****-****-****-************) - Runtime: iOS 13.7 (17H22) - DeviceType: iPhone 11

Thread 7 Crashed:: Dispatch queue: org.alamofire.session.rootQueue
0   libobjc.A.dylib                 0x00007fff512b7c6a objc_retain + 10
1   com.apple.Foundation            0x00007fff259243bf NSKeyValueWillChange + 510
2   com.apple.Foundation            0x00007fff25923ff7 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 487
3   com.apple.Foundation            0x00007fff259249f2 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 68
4   com.apple.Foundation            0x00007fff2591f6da _NSSetLongLongValueAndNotify + 269
5   com.apple.CFNetwork             0x00007fff230f3bfc 0x7fff22f52000 + 1711100
6   com.apple.Foundation            0x00007fff2594f28c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
7   com.apple.Foundation            0x00007fff2594f1ad -[NSBlockOperation main] + 80
8   com.apple.Foundation            0x00007fff259520dc __NSOPERATION_IS_INVOKING_MAIN__ + 17
9   com.apple.Foundation            0x00007fff2594e3ee -[NSOperation start] + 731
10  com.apple.Foundation            0x00007fff25952a20 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 17
11  com.apple.Foundation            0x00007fff25952540 __NSOQSchedule_f + 182
12  libdispatch.dylib               0x00007fff520e9344 _dispatch_block_async_invoke2 + 83
13  libdispatch.dylib               0x00007fff520dc8cb _dispatch_client_callout + 8
14  libdispatch.dylib               0x00007fff520e260c _dispatch_lane_serial_drain + 707
15  libdispatch.dylib               0x00007fff520e3044 _dispatch_lane_invoke + 388
16  libdispatch.dylib               0x00007fff520ed0c4 _dispatch_workloop_worker_thread + 626
17  libsystem_pthread.dylib         0x00007fff52301a3d _pthread_wqthread + 290
18  libsystem_pthread.dylib         0x00007fff52300b77 start_wqthread + 15

Versions

Please fill in the versions you're currently using:

  • apollo-ios SDK version: 0.34.0
  • Xcode version: 11.7 as well as 12.0
  • Swift version: 5.1 as well as 5.3

Steps to reproduce

Happens intermittently, hard to come up with exact steps.

dependency-management

Most helpful comment

@designatednerd I am also using Firebase

All 6 comments

That's a new one on me - under the hood we're using the same URLSessionClient that wraps URLSession as we were previously, so there shouldn't be anything messing with URLSession that wasn't already happening before.

The crash is happening on the Alamofire queue, but it looks like it's happening pretty deep within foundation when a block operation tries to change a value and it triggers KVO, and then something blows up.

Few questions:

  • Have you seen this happen on device or just on sim?
  • Have you cleaned your build folder since this happened?
  • Did Alamofire also update versions or is it still an older version?
  • Are you using the apollo-alamofire wrapper (which is totally separate from this repo) or are you just using AF in parallel to what we're doing?

I see several people have 馃憤'd this - any further details from anyone would be helpful

@designatednerd we have been doing some more experiments on our end, the common denominator so far seems to be recent versions of Firebase. We opened a separate issue in their repository hoping to get some insights on that, would be helpful to know if any of the other users upvoting this here are also using Firebase in their projects. Wondering if there might be some method swizzling going on somewhere? 馃

https://github.com/firebase/firebase-ios-sdk/issues/6734

Oh interesting - yes that definitely seems plausible. For what it's worth our codebase is entirely in Swift, which doesn't completely prevent us from using swizzling but does make it way more of a pain. Either way, we do not use any swizzling.

For others running into this issue, are you also using Firebase?

@designatednerd I am also using Firebase

OK - since the stack trace doesn't show anything from the Apollo API, we're not doing any swizzling that could cause the crashes in the stack trace, and there seems to be an issue with the Firebase SDK and other people having this issue seem to also be using Firebase, I'm going to close this issue and direct folks to the Firebase issue where this is being discussed in significantly more detail.

Thanks all for the heads up on this!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AnthonyMDev picture AnthonyMDev  路  4Comments

maxsz picture maxsz  路  4Comments

ashiemke picture ashiemke  路  5Comments

Dmurph24 picture Dmurph24  路  4Comments

plm75 picture plm75  路  4Comments