Caddy: v2: Panic when setting tls email block

Created on 30 Sep 2019  路  4Comments  路  Source: caddyserver/caddy

Version: 8eb2c3725199b17ae713dd0756a0e491e4829c12 on golang 1.13.1.

I was able to reproduce this panic starting with https://github.com/caddyserver/caddy/commit/b249b45d109cdfef51b94cdeeb1ef7593e3b26ab. Removing the tls [email protected] solves the problem and allows caddy to continue running.

www.pgp.dev {
    tls [email protected]
    redir https://pgp.dev{uri}
}

pgp.dev {
    tls [email protected]
    root * /var/www/
    encode gzip zstd
    file_server
}
# caddy run --config /etc/caddy/Caddyfile.v2 --config-adapter caddyfile
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa53b54]

goroutine 1 [running]:
github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile.ServerType.Setup(0xc0001e0000, 0x17, 0x20, 0xc00018a4e0, 0xc000126780, 0x6, 0x8, 0x0, 0x0, 0x0)
    /home/phil/caddy/caddyconfig/httpcaddyfile/httptype.go:185 +0x1da4
github.com/caddyserver/caddy/v2/caddyconfig/caddyfile.Adapter.Adapt(0xdd7c80, 0x1386d30, 0xc0001c0000, 0x10d1, 0x12d1, 0xc00018a4e0, 0xc0001030e0, 0xbe00000000c88000, 0xc000181ac0, 0xbe6027084cc2f65b, ...)
    /home/phil/caddy/caddyconfig/caddyfile/adapter.go:50 +0x19a
github.com/caddyserver/caddy/v2/cmd.loadConfig(0x7ffd8b02e69b, 0x17, 0x7ffd8b02e6c4, 0x9, 0x0, 0x0, 0x32, 0xc0000ed660, 0x40dcf6)
    /home/phil/caddy/cmd/main.go:141 +0x1d6
github.com/caddyserver/caddy/v2/cmd.cmdRun(0x0, 0x0, 0x0)
    /home/phil/caddy/cmd/commands.go:159 +0x24c
github.com/caddyserver/caddy/v2/cmd.Main()
    /home/phil/caddy/cmd/main.go:47 +0x8b
main.main()
    /home/phil/caddy/cmd/caddy/main.go:41 +0x20
bug

All 4 comments

Dangit. Thanks for the report. I've been having trouble with VSCode's Go tooling lately (with regards to gopls). In my case, I had used "Find all references" and I thought I got all the references to that pointer-type field prefaced with a nil check, but apparently one was missed. (Maybe more, sigh...)

I pushed a commit which fixes this. Sorry for the trouble... please pull and try again. :)

That fixes the problem when I do go run main.go run --config /etc/caddy/Caddyfile.v2 --config-adapter caddyfile, but a go build -a produced binary still throws the panic. I've tried clearing out my ${GOPATH}/pkg/mod folder before rebuilding too. Do you have any other steps I could take?

@pgporada Try clearing $GOPATH/pkg too? I don't actually know... I was able to reproduce your case and just re-verified that this fixes it as well. As for the build process, I'm not sure why it's not working for you... :(

That did it! Thanks!

Was this page helpful?
0 / 5 - 0 ratings