fix(cli): start lifetime modules before use in CLI commands#818
Open
A386official wants to merge 1 commit intofoxcpp:masterfrom
Open
fix(cli): start lifetime modules before use in CLI commands#818A386official wants to merge 1 commit intofoxcpp:masterfrom
A386official wants to merge 1 commit intofoxcpp:masterfrom
Conversation
The CLI subcommands (imap-acct, creds) load and configure modules from the config file but never call Start() on them. For storage.imapsql this leaves the Back field nil, so EnableUpdatePipe() dereferences a nil UpdateManager and panics with SIGSEGV. Call c.Lifetime.StartAll() in getCfgBlockModule() after module lookup so that backends are fully initialized before the CLI uses them. Also wire up c.Lifetime.StopAll() on error paths so modules are cleaned up properly when the type assertion fails. Fixes foxcpp#815
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.
Bug
maddy imap-acctandmaddy credsCLI subcommands crash with a nil pointer dereference (SIGSEGV) when used withstorage.imapsql:Root Cause
getCfgBlockModule()callsRegisterModules()thenc.Modules.Get(), which triggers lazyConfigure()on the target module. However, it never callsStart().For
storage.imapsql,Start()is what initializes theBackfield (thego-imap-sqlbackend). Without it,Backis nil. WhenopenStorage()then callsEnableUpdatePipe(), it dereferencesstore.Back.UpdateManager()on a nilBack, causing the SIGSEGV.The server path works correctly because
moduleMain()callsc.Lifetime.StartAll()after configuration, which invokesStart()on allLifetimeModuleinstances. The CLI path was missing this step.Fix
Call
c.Lifetime.StartAll()ingetCfgBlockModule()after the module is retrieved from the registry. This ensures all lifetime modules (including the storage backend and its dependencies) are fully started before the CLI tries to use them.Also wire up
c.Lifetime.StopAll()on error paths inopenStorage()andopenUserDB()so that started modules are cleaned up when the type assertion fails.Closes #815