Skip to content
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

fix panic child.Close() called without logger initialized #11117

Merged
merged 4 commits into from
Mar 15, 2022

Conversation

greedy52
Copy link
Contributor

Run into a CI failure where a panic happens when ServerContext tries to log an error message in reportStats but logger is not initialized yet.

Not sure what's the root cause that run into this. At the minimum should fix the crash.

@github-actions github-actions bot requested review from codingllama and jakule March 14, 2022 16:25
@@ -369,6 +369,9 @@ func NewServerContext(ctx context.Context, parent *sshutils.ConnectionContext, s
cancel: cancel,
}

// Pre-setup log entry in case early failures need to log something.
child.initLogEntry()

authPref, err := srv.GetAccessPoint().GetAuthPreference(ctx)
if err != nil {
childErr := child.Close()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

child.Close() calls reportStats which wants to log a message.

c.WithError(err).Warn("Failed to emit session data event.")

lib/srv/ctx.go Outdated Show resolved Hide resolved
@greedy52 greedy52 force-pushed the STeve/fix_a_panic_srv_ctx_close branch from ebac4aa to b39f105 Compare March 14, 2022 18:14
@greedy52 greedy52 requested a review from codingllama March 14, 2022 18:15
@greedy52 greedy52 enabled auto-merge (squash) March 15, 2022 13:50
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.

3 participants