Repository navigation
Fix a crash on narrow roads: clamp in MM2's order (0.3.1) - #4
Merged
Merged
Conversation
aiVehiclePhysics::CalcRoadTarget and CalcDestinationTarget clamp the target's offset across a road to +-h, h being the road's half-width less the car's side and 1 m, comparing the lower bound first: below -h gives -h, otherwise above h gives h. On a road narrower than that h is negative. OpenMM2 used std::clamp there, whose bounds must be ordered: a build with libstdc++'s assertions (a GCC 15+ debug build) aborted in a race with "Assertion '!(__hi < __lo)' failed", and an optimised one returned h where MM2 returns -h. ai::clampAcross keeps MM2's comparisons. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Fixes a crash in a race:
std::clamp ... Assertion '!(__hi < __lo)' failed(float). Version 0.3.1; the network protocol is unchanged.aiVehiclePhysics::CalcRoadTargetandCalcDestinationTargetclamp a target's offset across a road to ±h, where h is the road's half-width less the car's side and 1 m. On a road narrower than that, h is negative.std::clamp, whose bounds must be ordered. A build with libstdc++'s assertions (a GCC 15+ debug build) aborted. An optimised build returned h where MM2 returns -h.ai::clampAcrosskeeps that order at all seven sites inDrivingTargets.cpp.Testing:
ParityAiRoute.ClampAcrossKeepsMm2sOrderOnANarrowRoad.-D_GLIBCXX_ASSERTIONS, with no aborts.std::clampcall found no other float clamp whose bounds can cross in a race.🤖 Generated with Claude Code