Crash in NSURLCacheDBReader

We're getting this crash in our app and suspect it's a bug in CFNetwork. We use Alamofire (latest version). Seems from the stack something with trying to handle a request from the background? Is this issue known / seen by others?


Here is a snippet of the crash log:


Incident Identifier: 6EC9B455-E406-4E40-A511-79B474349DE4

CrashReporter Key: b331b621d790ae666f815ef9895a2a505399aca4

Hardware Model: iPhone11,8

Process: Stream [25811]

Path: /private/var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Stream

Identifier: com.microsoft.stream

Version: 7482 (1.1.12)

AppStoreTools: 11C29

AppVariant: 1:iPhone11,8:13

Code Type: ARM-64 (Native)

Role: Non UI

Parent Process: launchd [1]

Coalition: com.microsoft.stream [4167]


Date/Time: 2020-01-21 21:38:08.5997 +0100

Launch Time: 2020-01-21 21:30:37.2939 +0100

OS Version: iPhone OS 13.3 (17C54)

Release Type: User

Baseband Version: 2.03.07

Report Version: 104



Exception Type: EXC_BAD_ACCESS (SIGBUS)

Exception Subtype: KERN_MEMORY_ERROR at 0x0000000104974000 FS pagein error: 1 Operation not permitted

VM Region Info: 0x104974000 is in 0x104974000-0x10497c000; bytes after start: 0 bytes before end: 32767

REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL

WebKit Malloc 0000000104968000-0000000104974000 [ 48K] rw-/rwx SM=PRV

---> mapped file 0000000104974000-000000010497c000 [ 32K] rw-/rw- SM=PRV ...t_id=b9dd1eed

MALLOC metadata 000000010497c000-0000000104980000 [ 16K] r--/rwx SM=ZER ...one structure



Termination Signal: Bus error: 10

Termination Reason: Namespace SIGNAL, Code 0xa

Terminating Process: exc handler [25811]

Triggered by Thread: 13


Thread 13 name:

Thread 13 Crashed:

0 libsqlite3.dylib 0x0000000192feb190 walIndexTryHdr + 92 (sqlite3.c:41233)

1 libsqlite3.dylib 0x0000000192fe9ac0 walIndexReadHdr + 168 (sqlite3.c:67406)

2 libsqlite3.dylib 0x0000000192fe9ac0 walIndexReadHdr + 168 (sqlite3.c:67406)

3 libsqlite3.dylib 0x0000000192fe9388 walTryBeginRead + 580 (sqlite3.c:67729)

4 libsqlite3.dylib 0x0000000192fe78c8 sqlite3PagerSharedLock + 336 (sqlite3.c:67998)

5 libsqlite3.dylib 0x0000000192fe6d38 sqlite3BtreeBeginTrans + 512 (sqlite3.c:72596)

6 libsqlite3.dylib 0x00000001930064b4 sqlite3VdbeExec + 3344 (sqlite3.c:93696)

7 libsqlite3.dylib 0x00000001930041a4 sqlite3_step + 392 (sqlite3.c:88583)

8 CFNetwork 0x00000001945ff0a8 -[NSURLCacheDBReader createCachedResponseForKey:cacheDataPath:cacheDataFile:caller:] + 424 (NSURLCacheDBReader.mm:276)

9 CFNetwork 0x000000019467675c __CFURLCacheCopyResponseForRequestWithCompletionHandler + 1256 (CFURLCache.mm:2805)

10 CFNetwork 0x00000001947f72a0 CFXURLCache::getResponseForTask(NSURLSessionTask*, unsigned char, void (_CFCachedURLResponse cons... + 76 (XURLCache.mm:42)

11 CFNetwork 0x0000000194772cf0 invocation function for block in URLConnectionLoader::_loaderEvent_StartLoad(NSURLSessionTask*) + 244 (URLConnectionLoader.cpp:1582)

12 CFNetwork 0x000000019461049c -[__NSCFURLSessionTask _withXURLCache:] + 180 (SessionTask.mm:1991)

13 CFNetwork 0x0000000194772610 URLConnectionLoader::_loaderEvent_StartLoad(NSURLSessionTask*) + 1100 (URLConnectionLoader.cpp:1557)

14 CFNetwork 0x00000001946a09ac __61-[__NSCFURLLocalSessionConnection _tick_initialize_startLoad]_block_invoke + 140 (SessionConnection.mm:735)

15 CFNetwork 0x00000001945fdbc0 -[__NSCFURLLocalSessionConnection withLoaderOnQueue:] + 84 (SessionConnection.mm:647)

16 CFNetwork 0x00000001946a0914 -[__NSCFURLLocalSessionConnection _tick_initialize_startLoad] + 92 (SessionConnection.mm:731)

17 CFNetwork 0x00000001946a10bc __71-[__NSCFURLLocalSessionConnection initWithTask:delegate:delegateQueue:]_block_invoke + 44 (SessionConnection.mm:552)

18 libdispatch.dylib 0x000000019104639c _dispatch_block_async_invoke2 + 144 (queue.c:525)

19 libdispatch.dylib 0x0000000191039fd8 _dispatch_client_callout + 20 (object.m:495)

20 libdispatch.dylib 0x0000000191040450 _dispatch_lane_serial_drain + 568 (inline_internal.h:2484)

21 libdispatch.dylib 0x0000000191040eb4 _dispatch_lane_invoke + 424 (inline_internal.h:1851)

22 libdispatch.dylib 0x0000000191049f20 _dispatch_workloop_worker_thread + 580 (queue.c:6445)

23 libsystem_pthread.dylib 0x000000019109f6d0 _pthread_wqthread + 280 (pthread.c:2351)

24 libsystem_pthread.dylib 0x00000001910a59e8 start_wqthread + 8


Thread 13 crashed with ARM Thread State (64-bit):

x0: 0x000000011e809ba8 x1: 0x000000016fcf5de8 x2: 0x0000000000000000 x3: 0x0000000000000001

x4: 0x0000000000000000 x5: 0x0000000000000001 x6: 0x00000001229e9c90 x7: 0x0000000000000000

x8: 0x0000000000000000 x9: 0x0000000192fc8f54 x10: 0x000000011f005a60 x11: 0x0000000000000000

x12: 0x000000040000078c x13: 0x000001a1da7a43e9 x14: 0x00000000000001c5 x15: 0x0000000000000065

x16: 0x0000000193006470 x17: 0x00000001930139d4 x18: 0x0000000000000000 x19: 0x000000011f00c050

x20: 0x000000016fcf5de8 x21: 0x0000000104974000 x22: 0x0000000000000000 x23: 0x0000000000000001

x24: 0x0000000000000000 x25: 0x0000000000000002 x26: 0x000000011dfeadd0 x27: 0x000000016fcf5de8

x28: 0x000000011f002080 fp: 0x000000016fcf5c50 lr: 0x2b3ebc8192fe9ac0

sp: 0x000000016fcf5bc0 pc: 0x0000000192feb190 cpsr: 0x80000000

esr: 0x92000007 (Data Abort) byte read Translation fault


Binary Images:

0x100334000 - 0x10060bfff Stream arm64 <15d8167d7f88332e93eab280558aad71> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Stream

0x100770000 - 0x10081ffff ADAL arm64 <11c414535beb3c3182de96eb8e3f5ed0> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/ADAL.framework/ADAL

0x100920000 - 0x100977fff AZSClient arm64 <458a1b420cec334293bd8378ee939618> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/AZSClient.framework/AZSClient

0x100a04000 - 0x100a0bfff RCTActionSheet arm64 <0833986f0e113478add8015d34233182> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTActionSheet.framework/RCTActionSheet

0x100a24000 - 0x100a8bfff dyld arm64e <651eb4d8a0f03c97a0c46a8f6fc17a56> /usr/lib/dyld

0x100b08000 - 0x100bd7fff Alamofire arm64 <e3fddef368f5340c9a2313c96b09654b> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/Alamofire.framework/Alamofire

0x100d6c000 - 0x100d87fff CocoaLumberjack arm64 <627a9228d1ac3b0b91bf9b54c6e6a21b> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/CocoaLumberjack.framework/CocoaLumberjack

0x100dc0000 - 0x100dd3fff CoreModules arm64 <44c07a7448953402b3fa1d8ba6e6fd14> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/CoreModules.framework/CoreModules

0x100dfc000 - 0x100e0bfff DoubleConversion arm64 <ba159bb7fe1b37e18ae4c65cd459ab9e> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/DoubleConversion.framework/DoubleConversion

0x100e2c000 - 0x100e53fff FBReactNativeSpec arm64 <7d18c7a4160934278180dbd4bbbc150e> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/FBReactNativeSpec.framework/FBReactNativeSpec

0x100eb8000 - 0x100ecbfff FMDB arm64 <5748c63502fb3d42ac419ba8e6e443a0> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/FMDB.framework/FMDB

0x100eec000 - 0x101043fff FlipRecorder arm64 <d60f67e240f13481895a050012b1bdf7> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/FlipRecorder.framework/FlipRecorder

0x1012d0000 - 0x1012fffff KeychainAccess arm64 <4b897a0b762034ebbabc1fcbdb858408> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/KeychainAccess.framework/KeychainAccess

0x10133c000 - 0x1013f3fff Kingfisher arm64 <d93bd6d196593ed98d9e911f4db5bbb2> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/Kingfisher.framework/Kingfisher

0x101530000 - 0x10160ffff Macaw arm64 <6dd555338d8c318ea053f13ecdfe8a0e> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/Macaw.framework/Macaw

0x10175c000 - 0x101893fff OfficeUIFabric arm64 <6c5981eec08e3e8fab49ba4706c60b34> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/OfficeUIFabric.framework/OfficeUIFabric

0x101b90000 - 0x101bb3fff PowerLiftKit arm64 <9d74ece73d5f3a73aec9652029059267> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/PowerLiftKit.framework/PowerLiftKit

0x101be4000 - 0x101bf7fff RCTAnimation arm64 <cd50a6e1d2d83754b55cd3a85c79ad65> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTAnimation.framework/RCTAnimation

0x101c1c000 - 0x101c27fff RCTBlob arm64 <59d1035ee7af3f639395a8cb25c0d8b0> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTBlob.framework/RCTBlob

0x101c3c000 - 0x101c4bfff RCTImage arm64 <db1a0d4625d53635b02ec9715d360f52> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTImage.framework/RCTImage

0x101c6c000 - 0x101c73fff RCTLinking arm64 <b0eb428f0635341c953f0f348c1fd743> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTLinking.framework/RCTLinking

0x101c80000 - 0x101c93fff RCTNetwork arm64 <278b1bada90638519f1194ec584d4ab8> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTNetwork.framework/RCTNetwork

0x101cb0000 - 0x101cb7fff RCTSettings arm64 <d75ed1b1b63a30f9a5ac1e1ba812b719> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTSettings.framework/RCTSettings

0x101cc4000 - 0x101ce3fff RCTText arm64 <0616c5dfe73a30feb304b8b5ba6411ad> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTText.framework/RCTText

0x101d20000 - 0x101d27fff RCTTypeSafety arm64 <ad6381a2342f376ca898e51a52295fe1> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTTypeSafety.framework/RCTTypeSafety

0x101d34000 - 0x101d3bfff RCTVibration arm64 <557e611bb18531ed8c6d6f17b6783d3f> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RCTVibration.framework/RCTVibration

0x101d48000 - 0x101d53fff RNSensors arm64 <31240eeeaf78316caedc9f1d52a0db51> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/RNSensors.framework/RNSensors

0x101d68000 - 0x101e0ffff React arm64 <b215ad3dd22132b583d947809ba186fc> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/React.framework/React

0x101f30000 - 0x101f4bfff ReactCommon arm64 <e6aeaa850c0d3a4cb877c617a28c3880> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/ReactCommon.framework/ReactCommon

0x101f88000 - 0x101fabfff SWXMLHash arm64 <17305a7126f73f17bf5ccd0705c39e95> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/SWXMLHash.framework/SWXMLHash

0x101fe4000 - 0x102003fff cxxreact arm64 <c910382373e43211b0e29c58eae41af8> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/cxxreact.framework/cxxreact

0x10205c000 - 0x102087fff folly arm64 <1d68d50642853119be4bdf03fe4411c5> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/folly.framework/folly

0x1020d4000 - 0x1020e7fff glog arm64 <7db28b8e1e713c0b87e962e77543a913> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/glog.framework/glog

0x102118000 - 0x102133fff iOSLogging arm64 <3c6a264085a73fbb990c6b5d6932681d> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/iOSLogging.framework/iOSLogging

0x102158000 - 0x10216bfff jsi arm64 <395a8819e016350f9ed2e31a5dbba563> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/jsi.framework/jsi

0x102194000 - 0x10219bfff jsinspector arm64 <775bc7f59ac43f178fcf2964cd16a00f> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/jsinspector.framework/jsinspector

0x1021ac000 - 0x1021bbfff jsireact arm64 <046014f566f93e9a8f893df02da04600> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/jsireact.framework/jsireact

0x1021e4000 - 0x1021f3fff yoga arm64 <c7085f0ca75c38e0b14f5ba14b7116de> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/yoga.framework/yoga

0x102210000 - 0x102293fff AriaObjC arm64 <5e89b162f31f3925bcc7233755ab97e2> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/AriaObjC.framework/AriaObjC

0x102310000 - 0x102317fff IntuneMAMSwiftStub arm64 <d9df02d9c8013c2ba550b3e51f1ccc9e> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/IntuneMAMSwiftStub.framework/IntuneMAMSwiftStub

0x102328000 - 0x102583fff IntuneMAMWalledGardenSwift arm64 <a569fd609a14337ea652c5d2a965b1c7> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/IntuneMAMWalledGardenSwift.framework/IntuneMAMWalledGardenSwift

0x10292c000 - 0x10298ffff VideoUpload arm64 <5a1cff3cc0373cf297a7eab2186f24fc> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/VideoUpload.framework/VideoUpload

0x1029c4000 - 0x1029d3fff LiveStreamParser arm64 <885e1e3332143f48b87b7b86e6598a33> /var/containers/Bundle/Application/1DCF7A7E-C6A9-4190-B478-905442C501F7/Stream.app/Frameworks/LiveStreamParser.framework/LiveStreamParser

0x102aa4000 - 0x102aaffff libobjc-trampolines.dylib arm64e <028df612175838e498958fd8c6a9a03c> /usr/lib/libobjc-trampolines.dylib

0x190f6c000 - 0x190f82fff libsystem_trace.dylib arm64e <d8b2e2cdf750340388aba63c781581b9> /usr/lib/system/libsystem_trace.dylib

0x190f83000 - 0x190fb6fff libxpc.dylib arm64e <b7ae424e41d63a58a05cea0847830ddc> /usr/lib/system/libxpc.dylib

0x190fb7000 - 0x190fb7fff libsystem_blocks.dylib arm64e <298d0cb4af9b301ba31e0709413046f0> /usr/lib/system/libsystem_blocks.dylib

0x190fb8000 - 0x191036fff libsystem_c.dylib arm64e <4e543032e8f63ca69818e9f8fdb8f230> /usr/lib/system/libsystem_c.dylib

0x191037000 - 0x191073fff libdispatch.dylib arm64e <2afaf8647f5c3011840db066e7377af1> /usr/lib/system/libdispatch.dylib

0x191074000 - 0x191094fff libsystem_malloc.dylib arm64e <0407f7fab6853a3a8db328f2eb85d4b3> /usr/lib/system/libsystem_malloc.dylib

0x191095000 - 0x19109bfff libsystem_platform.dylib arm64e <cff9fe5cd8603000819ef5e15752dd46> /usr/lib/system/libsystem_platform.dylib

0x19109c000 - 0x1910a6fff libsystem_pthread.dylib arm64e <5f848a4c49073fc9a76d378fe8f2e4fc> /usr/lib/system/libsystem_pthread.dylib

0x1910a7000 - 0x1910d7fff libobjc.A.dylib arm64e <a486c2b341b03f23af40c5579f5be97e> /usr/lib/libobjc.A.dylib

0x1910d8000 - 0x191144fff libcorecrypto.dylib arm64e <7941b50b48d93654a5dfaf699a9db164> /usr/lib/system/libcorecrypto.dylib

0x191145000 - 0x191158fff libc++abi.dylib arm64e <9c6349615c4b3df3a717d62877ab3a95> /usr/lib/libc++abi.dylib

0x191159000 - 0x191187fff libsystem_kernel.dylib arm64e <4acde3c866303f879774d1741ea28f2b> /usr/lib/system/libsystem_kernel.dylib

0x191188000 - 0x1911bbfff libdyld.dylib arm64e <9059087b727b3b45b67209e5b03e6020> /usr/lib/system/libdyld.dylib

0x1911bc000 - 0x1911c4fff libsystem_darwin.dylib arm64e <a799ce1b3d243b0980f1a5fcfc1c11da> /usr/lib/system/libsystem_darwin.dylib

0x1911c5000 - 0x19121ffff libc++.1.dylib arm64e <d9f3508f9f743705ac7c83efcf279139> /usr/lib/libc++.1.dylib

0x191220000 - 0x191261fff libsystem_info.dylib arm64e <aca5c5c953ed38b0a9c8cc5b7963fcd2> /usr/lib/system/libsystem_info.dylib

...

That is a very interesting crash report. To start, look at this:

--->  mapped file            0000000104974000-000000010497c000 [   32K] rw-/rw- SM=PRV  ...t_id=b9dd1eed

The crashing address is inside a mapped file. That sort of thing is usually caused by the vnode pager getting a file I/O error. And then look up the log at this:

Exception Subtype: KERN_MEMORY_ERROR at 0x0000000104974000 FS pagein error: 1 Operation not permitted

I’ve never seen this before, but the interpretation is clear: The vnode pager got an

EPERM
error.

I’ve no idea how this might come about. How reproducible is this?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

So I haven't been able to get a local repo, but a small number of test flight users are able to hit it. I'm trying to understand what thread 13 is coming from - nothing in that stack trace appears to come from our app. Perhaps it's from an NSURLSession trying to run in the background? We use Alamofire for most of our http requests, but we also use React Native for a few as well.

I'm trying to understand what thread 13 is coming from … Perhaps it's from an NSURLSession trying to run in the background?

Thread 13 is

NSURLSession
doing dispatch async on to one of its internal queues. Frames 24…18 are the standard boilerplate you see for Dispatch worker threads. Frame 17 is a block associated with
-[__NSCFURLLocalSessionConnection initWithTask:delegate:delegateQueue:]
. While that’s not public API, it reasonably easy to get a handle on what it does just by the method signature.

We use Alamofire for most of our http requests

Right, and that uses

NSURLSession
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Just as an FYI, this is related to a long-standing bug in sqlite reported at least in 2012 for multiple platforms. I'm seeing the same stack trace starting at your frame 7. My failing code is in a third-party library that's accessing a local sqlite db when the app goes to the background. Apparently, the wal-index file is mmaped and accessing that file fails when the app goes to the background and sqlite doesn't handle this in a friendly way.

https://bugzilla.mozilla.org/show_bug.cgi?id=771138

https://www.sqlite.org/wal.html#noshm

Crash in NSURLCacheDBReader
 
 
Q