Skip to content

Use wrapping_add(1) in seqlock_begin_write for overflow consistency #2865

Description

@SaitejaKommi

Summary

seqlock_begin_write increments the generation counter using normal integer addition, while seqlock_end_write already uses wrapping_add.

Location

apis/python/node/src/lib.rs

Current behavior

The write-begin path increments the generation counter using:

pre_write_gen + 1

The write-end path already uses:

wrapping_add(2)

This creates inconsistent overflow handling.

In debug builds, normal integer addition can panic on overflow, whereas wrapping_add preserves the intended wrapping semantics of the sequence counter.

Suggested fix

Replace

pre_write_gen + 1

with

pre_write_gen.wrapping_add(1)

to make both write paths use consistent overflow behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpythonPython APIrust

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions