Skip to content

Native stack overflow in SimDrive::set_ach_speed: unbounded self-recursion on infeasible steps #326

Description

@jhoshiko

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

set_ach_speed

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions