fix: UB in movement path advancement - #76
Merged
ZivDero merged 4 commits intoAug 30, 2026
Merged
Conversation
Belonit
marked this pull request as draft
August 29, 2026 23:07
Evaluate the path index bound before reading blocker Path, preventing a one-past-end access when no sentinel is present.
Replace overlapping path shifts with centralized memmove-based advancement. Initialize and terminate path storage so completed steps cannot expose stale facings.
Validate path offsets and lengths before copying generated steps. Clear the regenerated suffix so paths remain terminated after success or failure.
Stop stationary-occupier traversal at FACING_COUNT, which represents a tunnel marker rather than a direction suitable for Adjacent_Cell.
Belonit
force-pushed
the
fix/recover-from-invalid-movement-paths
branch
from
August 30, 2026 11:03
cb7eea5 to
b6a391e
Compare
Belonit
marked this pull request as ready for review
August 30, 2026 11:10
Contributor
Author
|
Updated after identifying the root cause: overlapping memcpy calls corrupted movement paths while advancing them. The fix now uses overlap-safe path advancement instead of recovering from invalid directions after corruption. |
|
Development builds of b6a391e: The links work without a GitHub account. Artifacts expire after 90 days, and this comment follows the latest successful build. |
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
Fix invalid movement directions produced when locomotors advance an active path
with an overlapping
memcpy.Expected result: locomotors preserve every remaining path step and its
FACING_NONEterminator, so valid paths cannot expose uninitialized suffixentries during movement.
The four fixes are:
FootClass::Advance_Pathand usememmovefor the overlapping shift. Initialize the complete path in the constructor
and restore a canonical
FACING_NONEsuffix after every advancement.object path, and clear the regenerated suffix so failed or shorter path
searches cannot expose stale directions.
FACING_COUNT, which marks tunnelmovement and is not a direction accepted by
Adjacent_Cell.a separate one-past-end read when a terminator is missing.
Behavior and compatibility
Bug fix. Valid movement paths retain their existing behavior; path advancement
no longer depends on undefined overlapping-copy behavior. Maps, rules, saved
games, replays, network formats, deterministic simulation, and COM/ABI surfaces
are unchanged. No migration is required.
Validation
memcpy; changing only the operation tomemmovepreserved it.lengths with
memcpyand none withmemmove.foot.cpptranslation unit compiled successfully in theexperimental clang-cl Release configuration.
Documentation
No documentation change is needed. These are internal movement correctness
fixes that preserve the documented behavior and data formats.
Checklist