fix(python): use wrapping_add(1) in seqlock_begin_write for overflow consistency - #2866
Merged
trunk-io[bot] merged 1 commit intoJul 28, 2026
Merged
Conversation
Contributor
|
😎 Merged successfully - details. |
Collaborator
|
Automated review by Claude — this is a fully automated review; no human has vetted it. No issues found. Using Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Use
wrapping_add(1)inseqlock_begin_writeto provide consistent overflow handling for the seqlock generation counter.Fixes #2865
Root Cause
In
apis/python/node/src/lib.rs,seqlock_begin_writeincremented the generation counter usingpre_write_gen + 1, whileseqlock_end_writealready usedpre_write_gen.wrapping_add(2).Using normal integer addition can panic on
u64overflow in debug builds or when overflow checks are enabled, resulting in inconsistent overflow behavior between the begin and end write paths.Solution
pre_write_gen + 1withpre_write_gen.wrapping_add(1)inseqlock_begin_write.seqlock_end_write, ensuring the generation counter wraps consistently without panicking.Testing
cargo fmt --all -- --checkcargo check -p dora-node-api-pythonScope
This PR is intentionally limited to
apis/python/node/src/lib.rsand changes a single arithmetic operation to ensure consistent overflow handling. No functional APIs or runtime behavior were otherwise modified.