NatLabRockies / NatLabRockies/fastsim
Native stack overflow in SimDrive::set_ach_speed: unbounded self-recursion on infeasible steps
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 60
- Forks
- 19
- Avg merge
- 10d 2h
- Merged PRs (30d)
- 2
Description
sd.walk() can kill the host process with a native stack overflow (Windows exit 0xC00000FD, SIGSEGV on Linux) with no Python exception raised. I was able to trace the stack overflow to set_ach_speed, which recurses on itself (fastsim-core/src/simdrive/mod.rs:735) with no depth cap, and its only exit is the cyc_met check, a hard pwr_tractive <= pwr_prop_fwd_max with no tolerance. We could add a recursion/iteration cap on the correction (mirroring ach_speed_max_iter), or perhaps revise the criteria for stopping the recursion.
Reproduce:
import fastsim as fs
veh = fs.Vehicle.from_file("vehicles/2016 TOYOTA Corolla 4cyl 2WD.yaml")
veh.set_save_interval(1)
cyc = fs.Cycle.from_file("cycles/<any trip id from manifest>.yaml")
fs.SimDrive(veh, cyc).walk() # process dies natively
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the native crash with the provided Python example, then inspect set_ach_speed in fastsim-core/src/simdrive/mod.rs around the linked location and the reported recursion site. Trace the cyc_met stopping condition and compare the correction logic with ach_speed_max_iter. Done means infeasible steps no longer exhaust the native stack and the simulation exits or reports failure safely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 67/100