Skip to content

Fix cable check race condition causing permanent charger inoperability (#1392)#1900

Open
rishabhvaish wants to merge 2 commits intoEVerest:mainfrom
rishabhvaish:fix/cable-check-race-condition-1392
Open

Fix cable check race condition causing permanent charger inoperability (#1392)#1900
rishabhvaish wants to merge 2 commits intoEVerest:mainfrom
rishabhvaish:fix/cable-check-race-condition-1392

Conversation

@rishabhvaish
Copy link

Summary

  • Fixes a race condition between the detached cable_check thread and unplug handling in the state machine
  • When a car is unplugged during DC cable check, the detached thread can call fail_cable_check() after clear_errors_on_unplug() has already run
  • This leaves MREC11CableCheckFault permanently raised, making the charger inoperative until EVerest is restarted
  • Fix: check if the session has already ended (state is Idle or Finished) before raising the cable check fault error

Files changed

  • modules/EVSE/EvseManager/EvseManager.cpp — added state check in fail_cable_check() before raising error

Test plan

  • Start a DC charging session and unplug during cable check phase
  • Verify charger returns to Idle without permanent MREC11CableCheckFault
  • Verify normal cable check failures (e.g., isolation fault) still raise the error correctly
  • Verify next charging session starts successfully without reboot

Fixes #1392

@SebaLukas
Copy link
Member

Please resolve the conflicts before we can review your changes (updating your branch to latest main).

@SebaLukas SebaLukas self-assigned this Mar 2, 2026
@rishabhvaish rishabhvaish force-pushed the fix/cable-check-race-condition-1392 branch from a5fcb64 to fe1fcfd Compare March 3, 2026 07:25
…erability

When a car is unplugged during DC cable check, the detached cable_check
thread can call fail_cable_check() after clear_errors_on_unplug() has
already run, leaving MREC11CableCheckFault permanently raised. This makes
the charger inoperative until EVerest is restarted.

Add a state check before raising the fault: if the session has already
ended (Idle or Finished state), log the failure but skip raising the error.

Fixes EVerest#1392

Signed-off-by: Rishabh Vaish <rishabhvaish.904@gmail.com>
@rishabhvaish rishabhvaish force-pushed the fix/cable-check-race-condition-1392 branch from fe1fcfd to 5bf6514 Compare March 4, 2026 07:05
Comment on lines 2552 to 2558
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add your changes to this check. In your case if current_state is not Idle or Finished the error should be raised

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point — folded the Idle/Finished check into the existing raise_cable_check_fault guard in 71707f2 instead of the separate early return.

…ault guard

Merge the unplug state check into the same conditional block that
guards raise_cable_check_fault(), instead of a separate early return.

Signed-off-by: Rishabh Vaish <rishabhvaish.904@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition on EvseManager::fail_cable_check()

2 participants