fix(command): add nil check for GetCoreConfigInternal during SIGHUP reload#31935
Open
wucm667 wants to merge 1 commit into
Open
fix(command): add nil check for GetCoreConfigInternal during SIGHUP reload#31935wucm667 wants to merge 1 commit into
wucm667 wants to merge 1 commit into
Conversation
…eload Fixes hashicorp#31800 Sending SIGHUP to vault dev server in docker causes SIGSEGV (nil pointer dereference) since version 1.19. The stack trace points to command/server.go where GetCoreConfigInternal() returns nil in dev mode, but the reload handler doesn't check for nil before accessing its fields. Fix: Store the result of GetCoreConfigInternal() in a variable and check if it's not nil before accessing .Seals. If nil, log a warning and skip the seal reload gracefully. Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
|
@wucm667 is attempting to deploy a commit to the HashiCorp Team on Vercel. A member of the Team first needs to authorize it. |
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.
Fixes #31800
What did you do?
Started a vault dev server in docker and sent a HUP signal to trigger a config reload:
docker run --rm --name vault hashicorp/vault:latest server -devdocker kill --signal=HUP vaultWhat did you see instead?
Vault crashed with a panic:
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x961ac56]Stack trace pointed to
command/server.go:1692in(*ServerCommand).Run.Root Cause
GetCoreConfigInternal()returns nil in dev mode, but the SIGHUP reload handler does not check for nil before accessing.Sealson the returned config. This was working in 1.18 and lower but regressed in 1.19.Fix
Store the result of
GetCoreConfigInternal()in a variable and check if it's not nil before accessing.Seals. If nil, log a warning and skip the seal reload gracefully.Changes
command/server.go: Add nil check before accessingGetCoreConfigInternal().Sealsin two places (lines 1718 and 1721)Signed-off-by: wucm667 stevenwucongmin@gmail.com