sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

swizzleURLSessionTask crash: EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x7eab55f60

Open MilosStanojcic-TomTom opened this issue 1 year ago • 5 comments

Platform

iOS

Installed

Swift Package Manager

Version

8.11.0

Steps to Reproduce

Detected on Sentry dashboard. 24 events from 24 users. EXC_BAD_ACCESS __57+[SentryNetworkTrackingIntegration swizzleURLSessionTask]_block_invoke_2.29 Unhandled count > KERN_INVALID_ADDRESS at 0x7eab55f60.

Crashed in non-app
libobjc.A           +0x0032f8   objc_release                                                                                                                Hide 6 more frames
CoreFoundation      +0x039404   -[__NSArrayM removeObjectsInRange:]
[Our App]           +0x6432e8   -[SentryScope addBreadcrumb:] (SentryScope.m:126)
[Our App]           +0x626e10   -[SentryHub addBreadcrumb:] (SentryHub.m:488)
[Our App]           +0x641498   +[SentrySDK addBreadcrumb:] (SentrySDK.m:310)
[Our App]           +0x633778   -[SentryNetworkTracker addBreadcrumbForSessionTask:] (SentryNetworkTracker.m:487)
[Our App]           +0x632684   -[SentryNetworkTracker urlSessionTask:setState:] (SentryNetworkTracker.m:312)
[Our App]           +0x633fa0   __57+[SentryNetworkTrackingIntegration swizzleURLSessionTask]_block_invoke_2.29 (SentryNetworkTrackingIntegration.m:72)     In App
Called from
CFNetwork           +0x02ca38   CFHTTPMessageCopySerializedMessage                                                                                          Hide 15 more frames
CFNetwork           +0x02a7a4   CFHTTPMessageCopySerializedMessage
CFNetwork           +0x02b6bc   CFHTTPMessageCopySerializedMessage
CFNetwork           +0x02b5e8   CFHTTPMessageCopySerializedMessage
CFNetwork           +0x0a51d8   CFURLDownloadStart
CFNetwork           +0x0a251c   CFURLDownloadStart
CFNetwork           +0x0a5100   CFURLDownloadStart
CFNetwork           +0x1a78ac   _CFStreamErrorFromCFError
CFNetwork           +0x0a6db0   CFURLDownloadStart
libdispatch         +0x01324c   _dispatch_block_async_invoke2
libdispatch         +0x0042fc   _dispatch_client_callout
libdispatch         +0x00b890   _dispatch_lane_serial_drain
libdispatch         +0x00c3f4   _dispatch_lane_invoke
libdispatch         +0x017000   _dispatch_root_queue_drain_deferred_wlh
libdispatch         +0x016874   _dispatch_workloop_worker_thread
libsystem_pthread   +0x001960   _pthread_wqthread

Expected Result

No crash

Actual Result

Crash

Are you willing to submit a PR?

No response

MilosStanojcic-TomTom avatar Oct 12 '23 12:10 MilosStanojcic-TomTom

I see a couple of similar crashes in our internal SDK crash detection project. I @MilosStanojcic-TomTom, do you by any chance, have a way to reproduce this?

philipphofmann avatar Oct 12 '23 13:10 philipphofmann

@MilosStanojcic-TomTom, do you by any chance, have a way to reproduce this?

Sadly I don't. It is all from the dashboard and none hands on. All i can do is add more similar stack traces from other similar occurrences.

MilosStanojcic-TomTom avatar Oct 12 '23 17:10 MilosStanojcic-TomTom

Thanks for the update @MilosStanojcic-TomTom.

philipphofmann avatar Oct 13 '23 07:10 philipphofmann

@philipphofmann swizzleURLSessionTask crash look like this issue ?

zeqinjie avatar Oct 22 '23 02:10 zeqinjie

Yes, that could be related @zeqinjie. Thanks for the update.

philipphofmann avatar Oct 23 '23 14:10 philipphofmann

Still an issue today, Sentry iOS SDK v8.24.0

JoeFerrucci avatar May 29 '24 19:05 JoeFerrucci

Thanks for the update @JoeFerrucci.

philipphofmann avatar May 31 '24 10:05 philipphofmann

I checked some internal SDK crashes and identified two issues that can cause crashes like this. Many crashes happen due to insufficient memory when adding breadcrumbs, either by the SDK trying to increase the size of the breadcrumbs array or when trying to allocate memory for a debug log message. We fix the first issue with https://github.com/getsentry/sentry-cocoa/pull/4029 by using a ring buffer to avoid allocating extra memory when adding breadcrumbs. #4028 fixes the second problem. These two improvements should fix most of these crashes, but I'm not 100% sure. We are going to close this issue after we merged the two PRs. Please reopen if the problem persists in future versions.

philipphofmann avatar Jun 03 '24 09:06 philipphofmann