firebase / firebase/firebase-ios-sdk

apmpb_free_event_field

Open
#16,071 1 comment 0 reactions 0 assignees View on GitHub
api: analytics
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 14h
Merged PRs (30d)
72

Description

### Description

Reproduction Steps:

A fatal crash is occurring in the Firebase Analytics SDK, and it appears that a non-fatal error related to Crashlytics initialization occurs prior to this crash. Both issues occur in the same app version.

Issue 1 (Non-fatal Error):

A non-fatal error is explicitly logged on the main thread. Examining the stack trace reveals that the FBLPromise is rejected during [FIRCrashlytics waitForContextInit:callback:]. This indicates that a timeout or error occurred during Crashlytics context initialization.

Issue 2 (Fatal Crash):

A fatal crash (EXC_BAD_ACCESS) occurs on the background thread (com.google.fira.worker). This error occurs when the SDK attempts to upload cached event data ([APMMeasurement uploadData]) to the server. Specifically, the crash occurs during the memory deallocation step (apmpb_free_event_field) after parsing raw event data from the local SQLite store ([APMPBEvent initWithBuffer:]). Although we were unable to consistently reproduce this issue in our environment, we strongly suspect that the SDK state was corrupted due to a Crashlytics initialization failure (Issue 1), or that there were problems parsing a corrupted local database or freeing memory for specific event fields (Issue 2).

Could you please investigate the cause of the promise rejection during initialization and the subsequent incorrect access occurring during the analytics event cleanup process?

Stack Trace 1: Non-fatal Error (Crashlytics Init)
Non-fatal: Error
0 MyApplication 0x6e1520 FIRCLSUserLoggingRecordError + 407 (FIRCLSUserLogging.m:407)
1 MyApplication 0x702f90 __46-[FIRCrashlytics waitForContextInit:callback:]_block_invoke + 490 (FIRCrashlytics.m:490)
2 MyApplication 0x4c4b70 __56-[FBLPromise chainOnQueue:chainedFulfill:chainedReject:]_block_invoke.33 + 273 (FBLPromise.m:273)
3 libdispatch.dylib 0x1adc _dispatch_call_block_and_release
4 libdispatch.dylib 0x1b7fc _dispatch_client_callout
5 libdispatch.dylib 0x38b58 _dispatch_main_queue_drain.cold.5
6 libdispatch.dylib 0x10ec8 _dispatch_main_queue_drain
7 libdispatch.dylib 0x10e04 _dispatch_main_queue_callback_4CF
8 CoreFoundation 0x6a2b4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__

Stack Trace 2: Fatal Crash (Analytics Worker)
Crashed: com.google.fira.worker
0 MyApplication 0xab20a8 apmpb_free_event_field + 4306780
1 MyApplication 0xab21b8 apmpb_free_event + 4307052
2 MyApplication 0xac68cc -[APMPBEvent initWithBuffer:] + 4390784
3 MyApplication 0xa5e9e8 -[APMDatabase rawEventDataFromDictionary:error:] + 3965084
4 MyApplication 0xa93420 __59-[APMMeasurement(Bundle) rawEventsWithMetadataFingerprint:]_block_invoke + 4180692
5 MyApplication 0xaf02f0 -[APMSqliteStore recordsForQuery:parameterValues:error:withFilter:] + 4561316
6 MyApplication 0xa5df6c -[APMDatabase rawEventsWithMetadataFingerprint:error:eventFilter:] + 3962400
7 MyApplication 0xa93298 -[APMMeasurement(Bundle) rawEventsWithMetadataFingerprint:] + 4180300
8 MyApplication 0xa902a0 __41-[APMMeasurement(Bundle) bundleRawEvents]_block_invoke + 4168020
9 MyApplication 0xaf0600 -[APMSqliteStore performTransactionWithError:block:] + 4562100
10 MyApplication 0xa5c7bc -[APMDatabase performTransaction:] + 3956336
11 MyApplication 0xa90190 -[APMMeasurement(Bundle) bundleRawEvents] + 4167748
12 MyApplication 0xa87254 -[APMMeasurement uploadData] + 4131080
13 MyApplication 0xa86cbc __32-[APMMeasurement updateSchedule]_block_invoke_2 + 4129648
14 MyApplication 0xae7974 __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 4526120
15 libdispatch.dylib 0x1adc _dispatch_call_block_and_release + 32
16 libdispatch.dylib 0x1b7fc _dispatch_client_callout + 16

[\[apmpb_free_event_field\]issue_cc850cdc1dccff290c72e4f37f4222cd_crash_session_e7985e5d1ff343b58b43be83bdb7fcc5_DNE_0_v2_stacktrace.txt](https://github.com/user-attachments/files/26617160/apmpb_free_event_field.issue_cc850cdc1dccff290c72e4f37f4222cd_crash_session_e7985e5d1ff343b58b43be83bdb7fcc5_DNE_0_v2_stacktrace.txt)
[\[Non-fatal\]issue_72db735f7e880c771ada0499e7272403_error_session_42dcc59c50374256b8d51970ae3615dd_DNE_0_v2_stacktrace.txt](https://github.com/user-attachments/files/26617161/Non-fatal.issue_72db735f7e880c771ada0499e7272403_error_session_42dcc59c50374256b8d51970ae3615dd_DNE_0_v2_stacktrace.txt)

### Reproducing the issue

_No response_

### Firebase SDK Version

12.12.0

### Xcode Version

26.2

### Installation Method

Swift Package Manager

### Firebase Product(s)

Crashlytics, Analytics

### Targeted Platforms

iOS

### Relevant Log Output

```shell

```

### 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!

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.