New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Sprinkler] Initialize timers early to avoid crash #5499
Merged
Merged
Conversation
This file contains 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
Attempting to set `standby_switch` of a controller to ON at early boot stages results in the crash below. Such flow could be introduced by a switch that sets controller(s) to standby (i.e. a global disable switch). The issue is resolved by adding non-default constructor to `Sprinkler` class that initialized timers (valve selection and state machine ones) early, hence activating standby (and shutdown action it invokes internally) is now a safe operation. (gdb) bt #0 isr_hardfault () at /home/earle/Arduino/hardware/pico/rp2040/pico-sdk/src/rp2_common/pico_standard_link/crt0.S:98 esphome#1 <signal handler called> esphome#2 0x47701c18 in ?? () esphome#3 0x10016206 in std::function<void ()>::function(std::function<void ()> const&) () esphome#4 0x10016234 in esphome::sprinkler::Sprinkler::start_timer_(esphome::sprinkler::SprinklerTimerIndex) () esphome#5 0x10016292 in esphome::sprinkler::Sprinkler::fsm_transition_to_shutdown_() () esphome#6 0x100162d0 in esphome::sprinkler::Sprinkler::shutdown(bool) () esphome#7 0x100162f6 in esphome::sprinkler::ShutdownAction<>::play() () esphome#8 0x100149da in esphome::Action<>::play_complex() () esphome#9 0x10014caa in esphome::Trigger<>::trigger() [clone .isra.0] () esphome#10 0x10014cd8 in esphome::sprinkler::SprinklerControllerSwitch::write_state(bool) () esphome#11 0x100174f2 in esphome::switch_::Switch::turn_on() () esphome#12 0x1001d9c6 in std::_Function_handler<void (), setup::{lambda()esphome#48}>::_M_invoke(std::_Any_data const&) () esphome#13 0x1001d80c in esphome::LambdaAction<>::play() () esphome#14 0x100149da in esphome::Action<>::play_complex() () esphome#15 0x10017cae in esphome::Trigger<>::trigger() [clone .isra.0] () esphome#16 0x10017cdc in esphome::template_::TemplateSwitch::write_state(bool) () esphome#17 0x100174f2 in esphome::switch_::Switch::turn_on() () esphome#18 0x10017c0e in esphome::template_::TemplateSwitch::setup() () esphome#19 0x1001bdd0 in esphome::Component::call_setup() () esphome#20 0x1001beb0 in esphome::Component::call() () esphome#21 0x1001bbfe in esphome::Application::setup() () esphome#22 0x100252d4 in setup () esphome#23 0x00000000 in ?? ()
Hey there @kbx81, mind taking a look at this pull request as it has been labeled with an integration ( |
kbx81
approved these changes
Oct 9, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for finding and fixing this! Nice solution & bit of clean-up. 😄
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What does this implement/fix?
Attempting to set
standby_switch
of a controller to ON at early boot stages results in the crash below. Such flow could be introduced by a switch that sets controller(s) to standby (i.e. a global disable switch).The issue is resolved by adding non-default constructor to
Sprinkler
class that initializes timers (valve selection and state machine ones) early, hence activating standby (and shutdown action it invokes internally) is now a safe operation.Types of changes
Related issue or feature (if applicable): N/A
Pull request in esphome-docs with documentation (if applicable): N/A
Test Environment
Example entry for
config.yaml
:Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: