Skip to content

Fix panic in Firestore backend#56030

Merged
rosstimothy merged 1 commit intomasterfrom
tross/firestore_panic
Jun 24, 2025
Merged

Fix panic in Firestore backend#56030
rosstimothy merged 1 commit intomasterfrom
tross/firestore_panic

Conversation

@rosstimothy
Copy link
Copy Markdown
Contributor

 panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x5af856fc3494]

goroutine 62984 [running]:
github.com/gravitational/teleport/lib/backend/firestore.(*Backend).Items.func3-range1(0xc0001991f0, {0x0?, 0x0?})
        github.com/gravitational/teleport/lib/backend/firestore/firestorebk.go:586 +0x134
github.com/gravitational/teleport/lib/backend/firestore.(*Backend).Items.func3.(*Backend).mergedRecords.2-range1(0x5af85ed273a0?, {0x0, 0x0?})
        github.com/gravitational/teleport/lib/backend/firestore/firestorebk.go:655 +0x4f
github.com/gravitational/teleport/lib/itertools/stream.MergeStreams[...].func1()
        github.com/gravitational/teleport/lib/itertools/stream/stream.go:378 +0x236
github.com/gravitational/teleport/lib/backend/firestore.(*Backend).Items.func3.(*Backend).mergedRecords.2(0xc000e52500)
        github.com/gravitational/teleport/lib/backend/firestore/firestorebk.go:654 +0x89b
github.com/gravitational/teleport/lib/backend/firestore.(*Backend).Items.func3(0xc003bb4cc0)
        github.com/gravitational/teleport/lib/backend/firestore/firestorebk.go:579 +0x3bf

The above panic is caused by the snapShot not being set and thus resulting in a nil dereference. The snapShot is now assigned outside of the switch to ensure that all records that are successfully created contain a reference to a valid DocumentSnapshot.

```
 panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x5af856fc3494]

goroutine 62984 [running]:
github.com/gravitational/teleport/lib/backend/firestore.(*Backend).Items.func3-range1(0xc0001991f0, {0x0?, 0x0?})
        github.com/gravitational/teleport/lib/backend/firestore/firestorebk.go:586 +0x134
github.com/gravitational/teleport/lib/backend/firestore.(*Backend).Items.func3.(*Backend).mergedRecords.2-range1(0x5af85ed273a0?, {0x0, 0x0?})
        github.com/gravitational/teleport/lib/backend/firestore/firestorebk.go:655 +0x4f
github.com/gravitational/teleport/lib/itertools/stream.MergeStreams[...].func1()
        github.com/gravitational/teleport/lib/itertools/stream/stream.go:378 +0x236
github.com/gravitational/teleport/lib/backend/firestore.(*Backend).Items.func3.(*Backend).mergedRecords.2(0xc000e52500)
        github.com/gravitational/teleport/lib/backend/firestore/firestorebk.go:654 +0x89b
github.com/gravitational/teleport/lib/backend/firestore.(*Backend).Items.func3(0xc003bb4cc0)
        github.com/gravitational/teleport/lib/backend/firestore/firestorebk.go:579 +0x3bf
```

The above panic is caused by the snapShot not being set and thus
resulting in a nil dereference. The snapShot is now assigned outside
of the switch to ensure that all records that are successfully
created contain a reference to a valid DocumentSnapshot.
@rosstimothy rosstimothy added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v18 labels Jun 24, 2025
@rosstimothy rosstimothy marked this pull request as ready for review June 24, 2025 12:49
@rosstimothy rosstimothy requested a review from hugoShaka June 24, 2025 12:49
@github-actions github-actions Bot requested review from atburke and espadolini June 24, 2025 12:50
@rosstimothy rosstimothy enabled auto-merge June 24, 2025 13:48
@rosstimothy rosstimothy added this pull request to the merge queue Jun 24, 2025
Merged via the queue into master with commit e5df6f7 Jun 24, 2025
47 checks passed
@rosstimothy rosstimothy deleted the tross/firestore_panic branch June 24, 2025 14:11
@backport-bot-workflows
Copy link
Copy Markdown
Contributor

@rosstimothy See the table below for backport results.

Branch Result
branch/v18 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/branch/v18 no-changelog Indicates that a PR does not require a changelog entry size/sm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants