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 a panic when attempting to log when certificate should not be renewed #207

Merged
merged 1 commit into from
Sep 23, 2022

Conversation

antoniomika
Copy link
Contributor

In v0.17.1, we're seeing the following panic occur (and subsequently, no recovery) over at sish.

This occurs because we don't use zap for logging, which leads to loggerNamed returning nil. I went through and checked all other logger references and made sure they are guarded by the same issue by checking that log is not nil.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa1f3ca]

goroutine 537 [running]:
go.uber.org/zap.(*Logger).check(0x0, 0x2, {0xc8e025, 0x22})
	/go/pkg/mod/go.uber.org/zap@v1.23.0/logger.go:291 +0x6a
go.uber.org/zap.(*Logger).Error(0xc0000ee038?, {0xc8e025?, 0x4?}, {0xc00071d300, 0x1, 0x1})
	/go/pkg/mod/go.uber.org/zap@v1.23.0/logger.go:228 +0x3e
github.com/caddyserver/certmagic.(*Config).renewDynamicCertificate.func3({0xdbb248, 0xc001529da0}, 0xc00011acc0?)
	/go/pkg/mod/github.com/caddyserver/certmagic@v0.17.1/handshake.go:655 +0xbb7
created by github.com/caddyserver/certmagic.(*Config).renewDynamicCertificate
	/go/pkg/mod/github.com/caddyserver/certmagic@v0.17.1/handshake.go:699 +0x1293

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Aha, thank you.

What I might actually do soon is ensure a default log is always set... and then remove all the nil checks.

@mholt mholt merged commit 93fd493 into caddyserver:master Sep 23, 2022
@antoniomika antoniomika deleted the am/fix-log-nil-deref branch September 23, 2022 19:08
mholt added a commit that referenced this pull request Sep 26, 2022
Eliminates a bajillion nil checks and footguns
(except in tests, which bypass exported APIs, but that is expected)

Most recent #207

Logging can still be disabled via zap.NewNop(), if necessary.
(But disabling logging in CertMagic is a really bad idea.)
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.

None yet

2 participants