Instabug/Instabug-React-Native

Crash reports of errors on async functions wont work on iOS + SDK 14.1.0 with React Native 0.77.1

Closed this issue · 5 comments

Minimal repro repository

https://github.com/leonardorib/IssueInstabugCrashMinimalRepro

Steps to repro

  1. On a clean React Native 0.77.1 project, integrate with instabug and make sure the instabug sdk is initialized properly

  2. Add the following test error:

<Button
	title="Throw error async"
	onPress={async () => {
		const sleep = (ms: number) =>
			new Promise((resolve) => setTimeout(resolve, ms));
		console.log("Doing something async");
		await sleep(100);
		console.log("Something went wrong");
		throw new Error("This is an async test error");
	}}
/>

It must be async. When the error is thrown from a sync function, it's a fatal crash and it works normally. The issue is when it's from an async function.

  1. Build the release version of the project. (example: npx react-native run-ios --simulator "iPhone 16 Pro Max" --mode "Release"). The debug build won't repro cause crash reporting doesnt work at least by default.

  2. Trigger the test error.

Expected behavior

A non-fatal error should happen. When the error is thrown from an async function like in the example, it doesnt crash the app. But instabug should capture it and report as a non-fatal error on the dashboard with the error message.

This is the case on RN 0.77.0. However on 0.77.1 it is not behaving as expected.

Actual behavior

On 0.77.1, a fatal crash is caused, closing the app and the reported crash on instabug dashboard points to Instabug SDK itself, and not the error we just caused. From the crash report, this is the thread that fails:

data:text/text;charset=utf-8,
# Cause: -[NSNull length]: unrecognized selector sent to instance 0x1e3b3ba80
# Reported at: 2025-03-04 15:24:34 UTC

Thread 7 Queue 16: com.apple.root.user-initiated-qos (concurrent) [Crashed]:

0    CoreFoundation                           0x1804b9100     ___exceptionPreprocess
1    libobjc.A.dylib                          0x180092da8     _objc_exception_throw
2    CoreFoundation                           0x1804cebf4     +[NSObject(NSObject) instanceMethodSignatureForSelector:]
3    CoreFoundation                           0x1804bd40c     ____forwarding___
4    CoreFoundation                           0x1804bfb2c     __CF_forwarding_prep_0
5    Foundation                               0x1809d79d4     _$sSS10FoundationE36_unconditionallyBridgeFromObjectiveCySSSo8NSStringCSgFZ
6    Instabug                                 0x104f47e40     _prepareReportWriter
7    Instabug                                 0x104f278c4     _prepareReportWriter
8    IssueInstabugCrashRepro                  0x102e350f0     ___119-[InstabugCrashReportingBridge sendHandledJSCrash:userAttributes:fingerprint:nonFatalExceptionLevel:resolver:rejecter:]_block_invoke
9    libdispatch.dylib                        0x18017b314     __dispatch_call_block_and_release
10   libdispatch.dylib                        0x18017cc08     __dispatch_client_callout
11   libdispatch.dylib                        0x18018f8d0     __dispatch_root_queue_drain
12   libdispatch.dylib                        0x180190054     __dispatch_worker_thread2
13   libsystem_pthread.dylib                  0x103783b38     __pthread_wqthread
14   libsystem_pthread.dylib                  0x103782934     _start_wqthread

And this is the full crash report:

data:text/text;charset=utf-8,
# Cause: -[NSNull length]: unrecognized selector sent to instance 0x1e3b3ba80
# Reported at: 2025-03-04 15:24:34 UTC

Thread 0 Queue 1: com.apple.main-thread (serial):

0    libsystem_kernel.dylib                   0x1037fd390     _mach_msg2_trap
1    libsystem_kernel.dylib                   0x1038054f4     _mach_msg_overwrite
2    libsystem_kernel.dylib                   0x1037fd6cc     _mach_msg
3    CoreFoundation                           0x18041cae0     ___CFRunLoopServiceMachPort
4    CoreFoundation                           0x180417008     ___CFRunLoopRun
5    CoreFoundation                           0x180416704     _CFRunLoopRunSpecific
6    GraphicsServices                         0x190604b10     _GSEventRunModal
7    UIKitCore                                0x185b39180     -[UIApplication _run]
8    UIKitCore                                0x185b3d378     _UIApplicationMain
9    UIKitCore                                0x184f0fad4     _block_destroy_helper.22
10   IssueInstabugCrashRepro                  0x102e1bb24     _main

Thread 1 Unknown:

0    libsystem_kernel.dylib                   0x1037fee6c     ___workq_kernreturn
1    libsystem_pthread.dylib                  0x103782934     _start_wqthread

Thread 2 com.apple.uikit.eventfetch-thread:

0    libsystem_kernel.dylib                   0x1037fd390     _mach_msg2_trap
1    libsystem_kernel.dylib                   0x1038054f4     _mach_msg_overwrite
2    libsystem_kernel.dylib                   0x1037fd6cc     _mach_msg
3    CoreFoundation                           0x18041cae0     ___CFRunLoopServiceMachPort
4    CoreFoundation                           0x180417008     ___CFRunLoopRun
5    CoreFoundation                           0x180416704     _CFRunLoopRunSpecific
6    Foundation                               0x180f1f490     -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
7    Foundation                               0x180f1f6b0     -[NSRunLoop(NSRunLoop) runUntilDate:]
8    UIKitCore                                0x185be6a34     -[UIEventFetcher threadMain]
9    Foundation                               0x180f462d8     ___NSThread__start__
10   libsystem_pthread.dylib                  0x1037876f8     __pthread_start
11   libsystem_pthread.dylib                  0x103782940     _thread_start

Thread 3 Unknown:

0    libsystem_kernel.dylib                   0x1037fee6c     ___workq_kernreturn
1    libsystem_pthread.dylib                  0x103782934     _start_wqthread

Thread 4 com.facebook.react.runtime.JavaScript:

0    libsystem_kernel.dylib                   0x1037fd390     _mach_msg2_trap
1    libsystem_kernel.dylib                   0x1038054f4     _mach_msg_overwrite
2    libsystem_kernel.dylib                   0x1037fd6cc     _mach_msg
3    CoreFoundation                           0x18041cae0     ___CFRunLoopServiceMachPort
4    CoreFoundation                           0x180417008     ___CFRunLoopRun
5    CoreFoundation                           0x180416704     _CFRunLoopRunSpecific
6    IssueInstabugCrashRepro                  0x10301683c     +[RCTJSThreadManager runRunLoop]
7    Foundation                               0x180f462d8     ___NSThread__start__
8    libsystem_pthread.dylib                  0x1037876f8     __pthread_start
9    libsystem_pthread.dylib                  0x103782940     _thread_start

Thread 5 hades:

0    libsystem_kernel.dylib                   0x10380082c     ___psynch_cvwait
1    libc++.1.dylib                           0x18030529c     __ZNSt3__118condition_variable4waitERNS_11unique_lockINS_5mutexEEE
2    hermes                                   0x1045affc8     __ZN6hermes2vm7HadesGC8Executor6workerEv
3    hermes                                   0x1045aff30     __ZNSt3__114__thread_proxyB7v160006INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN6hermes2vm7HadesGC8ExecutorC1EvEUlvE_EEEEEPvSD_
4    libsystem_pthread.dylib                  0x1037876f8     __pthread_start
5    libsystem_pthread.dylib                  0x103782940     _thread_start

Thread 6 Unknown:

0    libsystem_kernel.dylib                   0x1037fd390     _mach_msg2_trap
1    libsystem_kernel.dylib                   0x1038054f4     _mach_msg_overwrite
2    libsystem_kernel.dylib                   0x1037fd6cc     _mach_msg
3    Instabug                                 0x104f65190     _IBGplcrash_async_macho_string_free
4    libsystem_pthread.dylib                  0x1037876f8     __pthread_start
5    libsystem_pthread.dylib                  0x103782940     _thread_start

Thread 7 Queue 16: com.apple.root.user-initiated-qos (concurrent) [Crashed]:

0    CoreFoundation                           0x1804b9100     ___exceptionPreprocess
1    libobjc.A.dylib                          0x180092da8     _objc_exception_throw
2    CoreFoundation                           0x1804cebf4     +[NSObject(NSObject) instanceMethodSignatureForSelector:]
3    CoreFoundation                           0x1804bd40c     ____forwarding___
4    CoreFoundation                           0x1804bfb2c     __CF_forwarding_prep_0
5    Foundation                               0x1809d79d4     _$sSS10FoundationE36_unconditionallyBridgeFromObjectiveCySSSo8NSStringCSgFZ
6    Instabug                                 0x104f47e40     _prepareReportWriter
7    Instabug                                 0x104f278c4     _prepareReportWriter
8    IssueInstabugCrashRepro                  0x102e350f0     ___119-[InstabugCrashReportingBridge sendHandledJSCrash:userAttributes:fingerprint:nonFatalExceptionLevel:resolver:rejecter:]_block_invoke
9    libdispatch.dylib                        0x18017b314     __dispatch_call_block_and_release
10   libdispatch.dylib                        0x18017cc08     __dispatch_client_callout
11   libdispatch.dylib                        0x18018f8d0     __dispatch_root_queue_drain
12   libdispatch.dylib                        0x180190054     __dispatch_worker_thread2
13   libsystem_pthread.dylib                  0x103783b38     __pthread_wqthread
14   libsystem_pthread.dylib                  0x103782934     _start_wqthread

Thread 8 Unknown:

0    libsystem_kernel.dylib                   0x1037fee6c     ___workq_kernreturn
1    libsystem_pthread.dylib                  0x103782934     _start_wqthread

Thread 9 Unknown:

0    IBGInvalidFramework                      0x104ee4938     0x104edc000

Thread 10 Unknown:

0    IBGInvalidFramework                      0x104ee4938     0x104edc000

Thread 11 Unknown:

0    IBGInvalidFramework                      0x104ee4938     0x104edc000

Thread 12 com.apple.NSURLConnectionLoader:

0    libsystem_kernel.dylib                   0x1037fd390     _mach_msg2_trap
1    libsystem_kernel.dylib                   0x1038054f4     _mach_msg_overwrite
2    libsystem_kernel.dylib                   0x1037fd6cc     _mach_msg
3    CoreFoundation                           0x18041cae0     ___CFRunLoopServiceMachPort
4    CoreFoundation                           0x180417008     ___CFRunLoopRun
5    CoreFoundation                           0x180416704     _CFRunLoopRunSpecific
6    CFNetwork                                0x184a09ce4     +[__CFN_CoreSchedulingSetRunnable _run:]
7    Foundation                               0x180f462d8     ___NSThread__start__
8    libsystem_pthread.dylib                  0x1037876f8     __pthread_start
9    libsystem_pthread.dylib                  0x103782940     _thread_start

Binary Images:

0x1037fc000     libsystem_kernel.dylib                       arm64e     5EA2A242-9786-3AF8-B8A9-7899ECC711C8
0x18038d000     CoreFoundation                               arm64e     6FC1E779-5846-3275-BF66-955738404CF6
0x190601000     GraphicsServices                             arm64e     3126E74D-FD21-3B05-9124-3B2FCF5DB07A
0x184cd9000     UIKitCore                                    arm64e     E83E0347-27D7-34BD-B0D3-51666DFDFD76
0x102e18000     IssueInstabugCrashRepro                      arm64e     F6EDD747-46DC-3825-B91F-FF63F336CF6C
0x103780000     libsystem_pthread.dylib                      arm64e     53372391-80EE-3A52-85D2-B0D39816A60B
0x1807da000     Foundation                                   arm64e     CF6B28C4-9795-362A-B563-7B1B8C116282
0x1802e5000     libc++.1.dylib                               arm64e     FB59D1E0-4DF5-3571-91CF-F5A90235BA68
0x1044e8000     hermes                                       arm64e     C6BA845F-7540-3624-9F81-4645F33FFF49
0x104b58000     Instabug                                     arm64e     9F41CAAB-FDF1-3A02-BD72-0C9CE50D0AC1
0x180068000     libobjc.A.dylib                              arm64e     A6716887-054E-32EE-8B87-A87811AA3599
0x180179000     libdispatch.dylib                            arm64e     EF0492A6-8CA5-38F0-97BB-DF9BDB54C17A
0x104edc000     IBGInvalidFramework                          arm64e     3ED7910B-B39A-4F15-9905-CAA6FA8228B3
0x104edc000     IBGInvalidFramework                          arm64e     2846A6A2-7990-4476-AEF9-743163D5E359
0x104edc000     IBGInvalidFramework                          arm64e     7299396E-15AC-4F65-8B1A-1293603C6DEB
0x184800000     CFNetwork                                    arm64e     4A0921B7-6BD8-3DD0-A7B0-17D82DBBC75A

How it looks on Instabug dashboard

RN 0.77.0

Image

RN 0.77.1

Image

Another probably related issue noticed

Even on RN 0.77.0, I noticed that when we tried to upgrade to 14.1.0, on release builds an error (non fatal) started to pop on our dashboard:

Error - Request has not been opened
main.jsbundle:1:300746

This seems to come from this line on react-native: https://github.com/facebook/react-native/blob/fef7933f63ab6fedff756e1e1c96ce3ca7c7f9dd/packages/react-native/Libraries/Network/XMLHttpRequest_new.js#L529

We revert the upgrade to 14.1.0 back to 14.0.0 and it stops happening. For this one I don't have clear steps yet, as it happens on our project but doesnt on a minimal project. But that is likely because our real project uses Instabug much more intensively with much more features and I was not able to detect exactly what is broken. But it clearly doesn't happen on 14.0.0, only when we upgrade to 14.1.0.

I may create another issue report for this one specifically but I think it is worth mentioning here because this one combined with the main issue being reported is very dangerous. Since when you upgrade to 0.77.1 a non-fatal error will crash Instabug crash reporter.

This issue has been automatically marked as pending feedback because we need additional information to be able to investigate it further. It will be closed in 7 days if it remains inactive. Thank you for your contributions.

This issue has been automatically marked as pending feedback because we need additional information to be able to investigate it further. It will be closed in 7 days if it remains inactive. Thank you for your contributions.

Please can you guys let me know what additional information you need? Since there is a minimal reproducer repository for the issue.

Apparently this: facebook/react-native#49873 solves the issue. I tested patching my RN with it in my minimal reproducer and it did fix.

There is a request to backport it: reactwg/react-native-releases#849

This issue has been automatically marked as pending feedback because we need additional information to be able to investigate it further. It will be closed in 7 days if it remains inactive. Thank you for your contributions.

This issue has been automatically closed since we haven't heard back from you. Please feel free to re-open the issue if you have more information to add.