caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
55.48k stars 3.91k forks source link

v2.8.0-rc.1: panic: runtime error: invalid memory address or nil pointer dereference #6336

Closed cattyhouse closed 1 month ago

cattyhouse commented 1 month ago
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux XCADDY_GO_BUILD_FLAGS="-ldflags '-s -w -buildid='" xcaddy build v2.8.0-rc.1 --output caddy-v2.8.0-rc.1-x86_64
example.com

respond "Hello, privacy!"
2024/05/22 23:39:54.908 INFO    using config from file  {"file": "./caddyfile"}
2024/05/22 23:39:54.909 INFO    adapted config to JSON  {"adapter": "caddyfile"}
2024/05/22 23:39:54.909 INFO    http.auto_https server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2024/05/22 23:39:54.910 INFO    http.auto_https enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2024/05/22 23:39:54.910 INFO    tls.cache.maintenance   started background certificate maintenance      {"cache": "0xc0004a5e00"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xad9c52]

goroutine 1 [running]:
github.com/caddyserver/caddy/v2.Context.AppIfConfigured({{0x0, 0x0}, 0x0, 0x0, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, ...}, ...)
        /Users/m1/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.8.0-rc.1/context.go:462 +0x32
github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).Cleanup(0xc00009de00)
        /Users/m1/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.8.0-rc.1/modules/caddytls/tls.go:356 +0xc5
github.com/caddyserver/caddy/v2.NewContext.func1()
        /Users/m1/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.8.0-rc.1/context.go:73 +0x162
github.com/caddyserver/caddy/v2.Validate(0xc000716d80)
        /Users/m1/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.8.0-rc.1/caddy.go:692 +0xb6
github.com/caddyserver/caddy/v2/cmd.cmdValidateConfig({0x0?})
        /Users/m1/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.8.0-rc.1/cmd/commandfuncs.go:547 +0x155
github.com/caddyserver/caddy/v2/cmd.init.1.func8.WrapCommandFuncForCobra.1(0xc000741b08, {0x1a4fd00?, 0x4?, 0x1a4fcd4?})
        /Users/m1/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.8.0-rc.1/cmd/cobra.go:137 +0x2f
github.com/spf13/cobra.(*Command).execute(0xc000741b08, {0xc0004664e0, 0x2, 0x2})
        /Users/m1/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0x2c88da0)
        /Users/m1/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/m1/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/caddyserver/caddy/v2/cmd.Main()
        /Users/m1/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.8.0-rc.1/cmd/main.go:75 +0x1d8
main.main()
        /Users/m1/make/caddy-trojan/buildenv_2024-05-23-0735.204431611/main.go:11 +0xf
mholt commented 1 month ago

Ooo! A bug in a prerelease! Rock on, thanks for the report!

cattyhouse commented 1 month ago

@mholt i am glad a bug is found. on the other hand, this indicates that such basic test was not run when caddy got released, do you think you could also add some tests before releasing?

mholt commented 1 month ago

Revamping our test suite is on my list, for sure.

milewski commented 1 month ago

Why this is only happening for me in a swarm cluster ... but exactly same version is not happening on my local?

mholt commented 1 month ago

@milewski Probably because this requires a very specific config situation. It's highly dependent on your config, and that's likely different from your local in your cluster.