firebase / firebase/firebase-ios-sdk

Crash After App Delete: Fatal Exception: NSRangeException

Open
#5,161 6 comments 0 reactions 0 assignees View on GitHub
api: database
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### [REQUIRED] Step 1: Describe your environment

* Xcode version: 11.3.1
* Firebase SDK version: 6.14.0
* Firebase Component: Core, Database
* Component version: 6.14.0
* Installation method: Carthage

### [REQUIRED] Step 2: Describe the problem

#### Steps to reproduce:

We're observing a crash that's slowly increasing when executing this code block:
```swift
database.purgeOutstandingWrites()
app.delete()
```

#### Stack Trace
```
Fatal Exception: NSRangeException
*** -[__NSArrayM objectAtIndexedSubscript:]: index 9223372036854775807 beyond bounds for empty array

Fatal Exception: NSRangeException
0 CoreFoundation 0x00007fff23c7127e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff513fbb20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23d03ab1 _CFThrowFormattedException + 194
3 CoreFoundation 0x00007fff23b8572e -[__NSArrayM objectAtIndexedSubscript:] + 142
4 Foo 0x0000000103c22a0c -[FWriteTree removeWriteId:] + 171
5 Foo 0x0000000103c0b2bd -[FSyncTree ackUserWriteWithWriteId:revert:persist:clock:] + 166
6 Foo 0x0000000103bf9a1d -[FRepo ackWrite:rerunTransactionsAtPath:status:] + 212
7 Foo 0x0000000103bf876b __39-[FRepo update:withNodes:withCallback:]_block_invoke + 114
8 Foo 0x0000000103bf1361 -[FPersistentConnection ackPuts] + 343
9 Foo 0x0000000103bf0de5 -[FPersistentConnection purgeOutstandingWrites] + 54
10 Foo 0x0000000103bf9144 -[FRepo purgeOutstandingWrites] + 287
11 Foo 0x0000000103bd37be __37-[FIRDatabase purgeOutstandingWrites]_block_invoke + 52
12 libdispatch.dylib 0x000000010d90fdd4 _dispatch_call_block_and_release + 12
13 libdispatch.dylib 0x000000010d910d48 _dispatch_client_callout + 8
14 libdispatch.dylib 0x000000010d9175ef _dispatch_lane_serial_drain + 788
15 libdispatch.dylib 0x000000010d91817f _dispatch_lane_invoke + 422
16 libdispatch.dylib 0x000000010d923a4e _dispatch_workloop_worker_thread + 719
17 libsystem_pthread.dylib 0x00007fff524636fc _pthread_wqthread + 290
18 libsystem_pthread.dylib 0x00007fff52462827 start_wqthread + 15

```

Contributor guide

Open the contributing guide

Research direction

Start with FWriteTree removeWriteId: and trace the acknowledgement path through FSyncTree ackUserWriteWithWriteId: and FRepo ackWrite:. Reproduce the sequence database.purgeOutstandingWrites() followed by app.delete() using Firebase SDK 6.14.0, then verify it no longer raises NSRangeException while purging outstanding writes.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c, swift
Domain
database, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.