Skip to content

Cap achieved-speed re-solves to fix native stack overflow in set_ach_speed - #335

Open
jhoshiko wants to merge 3 commits into
fastsim-3from
jdh/overflow-patch
Open

jhoshiko wants to merge 3 commits into
fastsim-3from
jdh/overflow-patch

Conversation

@jhoshiko

Copy link
Copy Markdown
Collaborator

set_ach_speed recursed without bound on some real-world trips, killing the process with a stack overflow that Python could not catch. This patch adds a maximum-depth sim param and a guard that returns a catchable error instead.

  • Adds SimParams.ach_speed_max_depth (default 100)
  • Adds a depth counter through a private helper, SimDrive::set_ach_speed_at_depth, which the public set_ach_speed now wraps to avoid changes to the function signature
  • The default value of 100 was chosen after a sweep across 312k real trips over 40 vehicles, with the deepest terminating trip needing 3 nested solves, and on the 337 crash cycles from the original report the deepest that still terminates needed 50. Nothing terminates between 50 and 100, and the crash cycles hit the cap at 100 and again at a probe cap of 500, so they are genuinely unbounded.
  • Adds a regression test with a synthetic infeasible cycle and a cap set to 1 to test the new depth guard

Joshua Hoshiko added 3 commits September 16, 2026 16:25
… max number of nested solves for achieved speed
…tion signature, added depth checks, added infeasible cycle dummy and test for the max depth sim param
@jhoshiko
jhoshiko requested a review from kylecarow September 16, 2026 23:28
@jhoshiko jhoshiko self-assigned this Sep 16, 2026
@jhoshiko jhoshiko added the bug Something isn't working label Sep 16, 2026
@jhoshiko

Copy link
Copy Markdown
Collaborator Author

Closes #326

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant