firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.55k stars 1.45k forks source link

Firebase iOS SDK crash [NSArray subarrayWithRange:]: range {1, 18446744073709551615} extends beyond bounds for empty array #13542

Open IdoMDigiBank opened 2 weeks ago

IdoMDigiBank commented 2 weeks ago

Description

we get crash [NSArray subarrayWithRange:]: range {1, 18446744073709551615} extends beyond bounds for empty array after we did not able to reproduce the crash we search our project for all the location we use subarrayWithRange the only locations we have subarrayWithRange is in the FirebaseSDK: image in this project we only use swift array that if it crash on extends beyond bounds for empty array we get different crash report from Xcode: One of the two will be used. Which one is undefined. Swift/Array.swift:419: Fatal error: Array index is out of range

Reproducing the issue

No response

Firebase SDK Version

10.29

Xcode Version

15.4

Installation Method

Swift Package Manager

Firebase Product(s)

Crashlytics

Targeted Platforms

iOS

Relevant Log Output

# Crashlytics - Stack trace
# Application: my app 
# Platform: apple
# Version: 2.10.0 (264)
# Issue: 7c94bea22f3dee4b38bfec7f9f4a9806
# Session: d0d6338b7cb24d6bb3fc41b1bc8415b8_DNE_0_v2
# Date: Thu Jul 25 2024 13:37:17 GMT+0300 (Israel Daylight Time)

Fatal Exception: NSRangeException

Crashed: com.google.firebase.crashlytics.ios.exceptionMyAPP
0  MyAPP                       0x2844330 FIRCLSProcessGetThreadState + 197 (FIRCLSProcess.c:197)
1  MyAPP                       0x2843294 FIRCLSProcessRecordThread + 423 (FIRCLSProcess.c:423)
2  MyAPP                       0x2842fc8 FIRCLSProcessRecordAllThreads + 487 (FIRCLSProcess.c:487)
3  MyAPP                       0x285ea1c FIRCLSHandler + 32 (FIRCLSHandler.m:32)
4  MyAPP                       0x285ded0 __FIRCLSExceptionRecord_block_invoke + 238 (FIRCLSException.mm:238)
5  libdispatch.dylib              0x3978 (Missing UUID b8c72eee14e73c88ae33a9bf80378af5)
6  libdispatch.dylib              0x135f0 (Missing UUID b8c72eee14e73c88ae33a9bf80378af5)
7  MyAPP                       0x285be38 FIRCLSExceptionRecord + 226 (FIRCLSException.mm:226)
8  MyAPP                       0x285d3cc FIRCLSExceptionRecordNSException + 124 (FIRCLSException.mm:124)
9  MyAPP                       0x285e35c FIRCLSCatchAndRecordActiveException(std::type_info*) + 401 (FIRCLSException.mm:401)
10 MyAPP                       0x285b8f4 FIRCLSTerminateHandler() + 456 (FIRCLSException.mm:456)
11 libc++abi.dylib                0x12c50 std::__terminate(void (*)()) + 12
12 libc++abi.dylib                0x12c00 std::terminate() + 52
13 libobjc.A.dylib                0x2bf5c objc_terminate + 12
14 libdispatch.dylib              0x398c (Missing UUID b8c72eee14e73c88ae33a9bf80378af5)
15 libdispatch.dylib              0x127c8 (Missing UUID b8c72eee14e73c88ae33a9bf80378af5)
16 libdispatch.dylib              0x122bc (Missing UUID b8c72eee14e73c88ae33a9bf80378af5)
17 CoreFoundation                 0x8d960 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
18 CoreFoundation                 0x88078 __CFRunLoopRun + 1936
19 CoreFoundation                 0x874d4 CFRunLoopRunSpecific + 572
20 GraphicsServices               0x3ae4 GSEventRunModal + 160
21 UIKitCore                      0xbf1a28 -[UIApplication _run] + 868
22 UIKitCore                      0xbf56b0 UIApplicationMain + 124
23 MyAPP                       0x18a9680 main + 19 (main.swift:19)
24 ???                            0x111401544 (Missing)
25 ???                            0x1115e20e0 (Missing)

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
```json Replace this line with the contents of your Package.resolved. ```

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
```yml Replace this line with the contents of your Podfile.lock! ```
google-oss-bot commented 2 weeks ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

rizafran commented 2 weeks ago

Hi @IdoMDigiBank, based on the logs you shared, the com.google.firebase.crashlytics.ios.exception thread only captures exceptions thrown elsewhere in order to record crash information, and it's actually not caused by Crashlytics. With this, could you provide a full stack trace of your issue?

IdoMDigiBank commented 2 weeks ago

Hi @rizafran add the full stack trace stacktrace.txt

samedson commented 3 days ago

This crash is a bit hard to decipher. The part of Crashlytics that uses subarrayWithRange is in logging, which happens throughout the life of the app, not during a crash.

The line that seems to be calling into the subarrayWithRange is cli_signalHandler. This may be another signal handler that I'm not aware of. Is it possible you have another SDK that could be installing signal handlers, like a crash reporter?

Crashed: com.google.firebase.crashlytics.ios.exception
0  MyAPP                       0xf4185c FIRCLSProcessRecordAllThreads + 392 (FIRCLSProcess.c:392)
1  MyAPP                       0xf41c3c FIRCLSProcessRecordAllThreads + 423 (FIRCLSProcess.c:423)
2  MyAPP                       0xf4fe50 FIRCLSHandler + 34 (FIRCLSHandler.m:34)
3  MyAPP                       0xf4fc54 __FIRCLSExceptionRecord_block_invoke + 240 (FIRCLSException.mm:240)
4  libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
5  libdispatch.dylib              0x132c4 _dispatch_lane_barrier_sync_invoke_and_complete + 56
6  MyAPP                       0xf4ebd0 FIRCLSExceptionRecord + 242 (FIRCLSException.mm:242)
7  MyAPP                       0xf4f718 FIRCLSExceptionRecordNSException + 126 (FIRCLSException.mm:126)
8  MyAPP                       0xf4e7d8 FIRCLSTerminateHandler() + 407 (FIRCLSException.mm:407)
9  libc++abi.dylib                0x14068 std::__terminate(void (*)()) + 16
10 libc++abi.dylib                0x1735c __cxa_get_exception_ptr + 86
11 libc++abi.dylib                0x172a0 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 306
12 libobjc.A.dylib                0x16180 objc_exception_throw + 420
13 CoreFoundation                 0xd7fd8 -[NSArray subarrayWithRange:] + 884
14 MyAPP                       0x180f3e0 cli_signalHandler + 4390007776
15 MyAPP                       0xf50fbc FIRCLSSignalSafeInstallPreexistingHandlers + 54 (FIRCLSSignal.c:54)
16 MyAPP                       0xf50d80 FIRCLSSignalHandler + 332 (FIRCLSSignal.c:332)
17 libsystem_platform.dylib       0xe9c _sigtramp + 56
18 Foundation                     0x5ff9c _NSKeyValueObservationInfoGetObservances + 268
19 Foundation                     0x19264 NSKeyValueWillChangeWithPerThreadPendingNotifications + 236
20 WebKit                         0xf6b8c <redacted> + 40
21 WebKit                         0xf2ed8 <redacted> + 832
22 WebKit                         0xf2800 <redacted> + 684
23 WebKit                         0xf2530 <redacted> + 48
24 WebKit                         0x8da924 <redacted> + 1624
25 WebKit                         0x8da22c <redacted> + 84
26 WebKit                         0xd8f06c <redacted> + 68
27 JavaScriptCore                 0x5a9e8 WTF::RunLoop::performWork() + 204
28 JavaScriptCore                 0x5b910 WTF::RunLoop::performWork(void*) + 36
29 CoreFoundation                 0x56834 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
30 CoreFoundation                 0x567c8 __CFRunLoopDoSource0 + 176
31 CoreFoundation                 0x542f8 __CFRunLoopDoSources0 + 340
32 CoreFoundation                 0x53484 __CFRunLoopRun + 828
33 CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
34 GraphicsServices               0x11a8 GSEventRunModal + 164
35 UIKitCore                      0x40a90c -[UIApplication _run] + 888
36 UIKitCore                      0x4be9d0 UIApplicationMain + 340
37 MyAPP                       0x806c main + 19 (main.swift:19)
38 ???                            0x1bb0f9e4c (Missing)