Skip to content

fix(deltatracker): clear the resized variable's dirty flag, not the next - #74

Merged
Segfaultd merged 1 commit into
masterfrom
fix/delta-tracker-resize-dirty
Oct 16, 2026
Merged

Segfaultd merged 1 commit into
masterfrom
fix/delta-tracker-resize-dirty

Conversation

@Segfaultd

@Segfaultd Segfaultd commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Problem

VariableListDeltaTracker::WriteVar, in the branch taken when a variable's serialized size changes, advanced nextWriteIndex before clearing isDirty:

nextWriteIndex++;
variableList[nextWriteIndex].isDirty=false;
  • The resized variable kept its dirty flag, so it was sent again on the next pass even though it had not changed.
  • The next variable lost its dirty flag, whether FlagDirtyFromBitArray set it or a lost-send receipt did. If its value was unchanged it was not resent, which is the update the flag exists to force.
  • Resizing the last variable wrote one past the end of the list. Debug builds assert in List::operator[].

Any variable-length type triggers it (RakString, std::string, containers), so it hits ReplicaManager3 entities that use VariableDeltaSerializer. The MafiaHub Framework is about to mark forced fields dirty this way after a server override (MafiaHub/Framework#325), and a string field resized just before one of them would silently cancel that resend.

Change

Clear the flag before advancing the index. The fix is one line.

Testing

New Tests/Unit/VariableListDeltaTrackerTests.cpp, one case per symptom. All three failed before the fix, the last one on the bounds assert:

  • ResizedValueKeepsTheNextVariableDirty
  • ResizedValueClearsItsOwnDirtyFlag
  • ResizingTheLastVariableStaysInBounds

With the fix, the full UnitTests binary passes (215/215, Windows Debug).

Summary by CodeRabbit

  • Bug Fixes
    • Corrected update handling when a variable’s serialized size changes, so its dirty state is cleared on the correct entry. This helps ensure subsequent variables are processed accurately, including when the resized variable is the last item in the list.

When a variable's serialized size changed, WriteVar advanced the index
before clearing isDirty. The resized variable kept its flag and was
resent on the next pass, the following variable lost a flag set by
FlagDirtyFromBitArray or a lost-send receipt, and resizing the last
variable wrote one past the end of the list.
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ad292bab-a515-4e43-a43e-2a2cc057d593
📥 Commits

Reviewing files that changed from the base of the PR and between 0082e08 and 24c36f2.

📒 Files selected for processing: 2
  • Source/include/mafianet/variable_list_delta_tracker.h
  • Tests/Unit/VariableListDeltaTrackerTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

WriteVar now clears the resized variable’s dirty flag before advancing the write index. Unit tests cover unchanged values, dirty flags around resized values, and resizing the last variable.

Changes

Variable list tracking

Layer / File(s) Summary
Resized variable dirty-flag handling
Source/include/mafianet/variable_list_delta_tracker.h, Tests/Unit/VariableListDeltaTrackerTests.cpp
WriteVar clears the current entry’s dirty flag before advancing the index when the serialized size changes. Tests cover unchanged writes, dirty flags, and resizing the last variable.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 24c36

This fixes the wrong dirty flag being cleared when a variable is resized, and it removes a potential out-of-bounds access. No merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main fix: clearing the resized variable's dirty flag instead of the next variable's flag.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I’m a rabbit checking bits,
A resized string now clears its flag.
The next index waits its turn,
Tests watch each value change.
One last variable reaches the end,
I hop away through tidy rows.

Comment @coderabbitai help to get the list of available commands.

@Segfaultd
Segfaultd merged commit 48be2f6 into master Oct 16, 2026
7 checks passed
@Segfaultd
Segfaultd deleted the fix/delta-tracker-resize-dirty branch October 16, 2026 08:29
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.

1 participant