Skip to content

read_snapshot_obj: Pass user_ctx by reference to fix race condition#836

Merged
koujl merged 1 commit intoeBay:masterfrom
koujl:user_ctx
Dec 8, 2025
Merged

read_snapshot_obj: Pass user_ctx by reference to fix race condition#836
koujl merged 1 commit intoeBay:masterfrom
koujl:user_ctx

Conversation

@koujl
Copy link
Contributor

@koujl koujl commented Dec 4, 2025

There is a race condition where read_snapshot_obj may access a freed user_ctx pointer due to concurrent free_user_snp_ctx calls. This occurs because user_ctx was stored in the snapshot_obj struct as an intermediate copy, making it vulnerable to being freed while still in use.

Fix by passing user_ctx as a reference parameter, allowing the listener to modify the caller's context directly without intermediate storage.

@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.64%. Comparing base (1a0cef8) to head (8745850).
⚠️ Report is 293 commits behind head on master.

Files with missing lines Patch % Lines
...rc/lib/replication/repl_dev/raft_state_machine.cpp 0.00% 3 Missing ⚠️
src/include/homestore/replication/repl_dev.h 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #836      +/-   ##
==========================================
- Coverage   56.51%   49.64%   -6.88%     
==========================================
  Files         108      110       +2     
  Lines       10300    11309    +1009     
  Branches     1402     5327    +3925     
==========================================
- Hits         5821     5614     -207     
+ Misses       3894     2081    -1813     
- Partials      585     3614    +3029     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

There is a race condition where read_snapshot_obj may access a freed
user_ctx pointer due to concurrent free_user_snp_ctx calls. This occurs
because user_ctx was stored in the snapshot_obj struct as an
intermediate copy, making it vulnerable to being freed while still in
use.

Fix by passing user_ctx as a reference parameter, allowing the listener
to modify the caller's context directly without intermediate storage.

Signed-off-by: Jilong Kou <jkou@ebay.com>
Copy link
Collaborator

@xiaoxichen xiaoxichen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@koujl koujl requested review from Besroy and yamingk December 5, 2025 07:45
@koujl koujl merged commit 7f1a005 into eBay:master Dec 8, 2025
21 checks passed
@koujl koujl deleted the user_ctx branch December 8, 2025 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants