Fix boot crash: guard ESP_LOG during static initialization#18
Open
psarossy wants to merge 1 commit intobullshit:mainfrom
Open
Fix boot crash: guard ESP_LOG during static initialization#18psarossy wants to merge 1 commit intobullshit:mainfrom
psarossy wants to merge 1 commit intobullshit:mainfrom
Conversation
Protocol registration functions (register_protocol_for_vendor, register_fallback_protocol, ensure_initialized) are called during C++ static initialization via REGISTER_UPS_PROTOCOL_FOR_VENDOR and REGISTER_UPS_FALLBACK_PROTOCOL macros. At this point the ESPHome Logger has not yet been constructed, so ESP_LOG* calls dereference a null global_logger pointer, causing: Guru Meditation Error: Core 0 panic'ed (LoadProhibited) EXCVADDR: 0x0000002c Guard all three ESP_LOG calls with a null check on global_logger so they still log when called at runtime but are safely skipped during static init. Fixes bullshit#17 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ESP_LOG*calls inprotocol_factory.cppwithglobal_logger != nullptrchecksREGISTER_UPS_*macros) before the ESPHome Logger is constructedGuru Meditation Error: Core 0 panic'ed (LoadProhibited)atEXCVADDR: 0x0000002con every bootRoot Cause
REGISTER_UPS_PROTOCOL_FOR_VENDOR/REGISTER_UPS_FALLBACK_PROTOCOLmacros create file-scope static variables whose constructors callregister_protocol_for_vendor()→ensure_initialized()→ESP_LOGD()duringdo_global_ctors, beforemain()runs.Test plan
Fixes #17
🤖 Generated with Claude Code