Skip to content

Fix SIGSEGV in historical RPC queries#3098

Merged
masih merged 1 commit intomainfrom
masih/mmap-copy-fix
Mar 20, 2026
Merged

Fix SIGSEGV in historical RPC queries#3098
masih merged 1 commit intomainfrom
masih/mmap-copy-fix

Conversation

@masih
Copy link
Copy Markdown
Collaborator

@masih masih commented Mar 20, 2026

When serving historical queries, rootmulti.Store.Query() opens a read-only memiavl instance (mmap'd), queries it, and defers Close(). The response byte slices (Key, Value) may point directly into the mmap'd region. When the deferred Close() unmaps the memory before JSON marshaling reads the response, the process segfaults (observed on arctic-1.

Copies res.Key and res.Value for non-latest queries so they survive the mmap unmap.

Separated out from #3095 to capture a clear commit history of changes for the future archeologists.

When serving historical queries, rootmulti.Store.Query() opens a read-only memiavl instance (mmap'd), queries it, and defers Close(). The response byte slices (Key, Value) may point directly into the mmap'd region. When the deferred Close() unmaps the memory before JSON marshaling reads the response, the process segfaults.

Copies res.Key and res.Value for non-latest queries so they survive the mmap unmap.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 20, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMar 20, 2026, 2:43 PM

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.71%. Comparing base (02b141d) to head (a021080).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3098   +/-   ##
=======================================
  Coverage   58.71%   58.71%           
=======================================
  Files        2094     2094           
  Lines      172970   172975    +5     
=======================================
+ Hits       101555   101560    +5     
  Misses      62430    62430           
  Partials     8985     8985           
Flag Coverage Δ
sei-chain-pr 46.61% <100.00%> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-cosmos/storev2/rootmulti/store.go 46.97% <100.00%> (+0.47%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@masih masih added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit 145f854 Mar 20, 2026
43 of 44 checks passed
@masih masih deleted the masih/mmap-copy-fix branch March 20, 2026 15:50
github-actions bot pushed a commit that referenced this pull request Mar 20, 2026
When serving historical queries, rootmulti.Store.Query() opens a
read-only memiavl instance (mmap'd), queries it, and defers Close(). The
response byte slices (Key, Value) may point directly into the mmap'd
region. When the deferred Close() unmaps the memory before JSON
marshaling reads the response, the process segfaults (observed on
`arctic-1`.

Copies res.Key and res.Value for non-latest queries so they survive the
mmap unmap.

Separated out from #3095
to capture a clear commit history of changes for the future
archeologists.

(cherry picked from commit 145f854)
@seidroid
Copy link
Copy Markdown

seidroid bot commented Mar 20, 2026

Successfully created backport PR for release/v6.4:

masih added a commit that referenced this pull request Mar 20, 2026
Backport of #3098 to `release/v6.4`.

Co-authored-by: Masih H. Derkani <m@derkani.org>
github-merge-queue bot pushed a commit that referenced this pull request Mar 21, 2026
## Describe your changes and provide context
This PR completely disable zero copy for SC to avoid segfault exception.
It also reverts #3098

## Testing performed to validate your change

---------

Co-authored-by: Masih H. Derkani <m@derkani.org>
github-actions bot pushed a commit that referenced this pull request Mar 21, 2026
## Describe your changes and provide context
This PR completely disable zero copy for SC to avoid segfault exception.
It also reverts #3098

## Testing performed to validate your change

---------

Co-authored-by: Masih H. Derkani <m@derkani.org>
(cherry picked from commit b1cb904)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants