caddy icon indicating copy to clipboard operation
caddy copied to clipboard

slice bounds out of range

Open PeeZu opened this issue 7 years ago • 9 comments

1. Which version of Caddy are you using (caddy -version)?

1.0.2

2. What are you trying to do?

validate the Caddyfile

3. What is your Caddyfile?

:80 {

}

OR

:443 {

}

4. How did you run Caddy (give the full command and describe the execution environment)?

just try to validate the Caddyfile with: caddy -validate -conf /path/to/your/caddyfile

5. Please paste any relevant HTTP request(s) here.

6. What did you expect to see?

Caddyfile is valid

7. What did you see instead (give full error messages and/or log)?

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/caddyserver/caddy/caddyhttp/httpserver.Address.Key(...)
        /Users/matt/Dev/src/github.com/caddyserver/releaser/cmd/release-caddy/buildenv_08-13-1452.612513987/main/vendor/github.com/caddyserver/caddy/caddyhttp/httpserver/plugin.go:494
github.com/caddyserver/caddy/caddyhttp/httpserver.(*httpContext).InspectServerBlocks(0xc000144c90, 0xc00002a270, 0x27, 0xc00014c180, 0x1, 0x1, 0xc00014c180, 0x1, 0x1, 0x0, ...)
        /Users/matt/Dev/src/github.com/caddyserver/releaser/cmd/release-caddy/buildenv_08-13-1452.612513987/main/vendor/github.com/caddyserver/caddy/caddyhttp/httpserver/plugin.go:143 +0x12f5
github.com/caddyserver/caddy.ValidateAndExecuteDirectives(0xd56ca0, 0xc00014b000, 0xc00016e100, 0xc00014b001, 0x0, 0x0)
        /Users/matt/Dev/src/github.com/caddyserver/releaser/cmd/release-caddy/buildenv_08-13-1452.612513987/main/vendor/github.com/caddyserver/caddy/caddy.go:614 +0x3be
github.com/caddyserver/caddy/caddy/caddymain.Run()
        /Users/matt/Dev/src/github.com/caddyserver/releaser/cmd/release-caddy/buildenv_08-13-1452.612513987/main/vendor/github.com/caddyserver/caddy/caddy/caddymain/run.go:182 +0x90d
main.main()
        main/main.go:11 +0x2e

8. Why is this a bug, and how do you think this should be fixed?

Server doesn't start as expected

9. What are you doing to work around the problem in the meantime?

revert to previous version 1.0.1

PeeZu avatar Aug 14 '19 06:08 PeeZu

Experiencing the same thing


goroutine 1 [running]:
github.com/caddyserver/caddy/caddyhttp/httpserver.Address.Key(...)
	/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddyhttp/httpserver/plugin.go:494
github.com/caddyserver/caddy/caddyhttp/httpserver.(*httpContext).InspectServerBlocks(0xc000031170, 0x7ffe3b639f5c, 0xf, 0xc0001e6100, 0x3, 0x4, 0xc0001e6100, 0x3, 0x4, 0x0, ...)
	/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddyhttp/httpserver/plugin.go:143 +0x12ee
github.com/caddyserver/caddy.ValidateAndExecuteDirectives(0xea5f00, 0xc00003ad40, 0xc0001fc200, 0xc0001fc200, 0x1, 0xc00000e058)
	/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddy.go:614 +0x3b7
github.com/caddyserver/caddy.startWithListenerFds(0xea5f00, 0xc00003ad40, 0xc0001fc200, 0x0, 0x0, 0x0)
	/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddy.go:516 +0x125
github.com/caddyserver/caddy.Start(0xea5f00, 0xc00003ad40, 0xea5f00, 0xc00003ad40, 0x0)
	/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddy.go:473 +0xea
github.com/caddyserver/caddy/caddy/caddymain.Run()
	/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddy/caddymain/run.go:193 +0x646
main.main()
	main/main.go:17 +0x27

I have tried 0.0.0.0:80, *:80 and :80. All variations give this error.

DanyHenriquez avatar Aug 14 '19 07:08 DanyHenriquez

Same issue using the docker image.

ABeltramo avatar Aug 14 '19 07:08 ABeltramo

From the comment with version 1.0.2 release

One minor breaking change in Go 1.12.8 might affect some configurations that use service name in the port of their Caddyfiles, like so: example.com:https - we've smoothed this over so the behavior of Caddy is the same but if you encounter any odd inconsistencies, switch to using numeric ports or proper URL scheme: either https://example.com (recommended) or example.com:443.

DanyHenriquez avatar Aug 14 '19 08:08 DanyHenriquez

I found a fix

We used *:80 and other versions of this definition.

Change it to http://*:80. So put the protocol in front of it and caddy will start with version 1.0.2.

This is also in line with the comment attached to the release.

Hope this will help you guys too :)

DanyHenriquez avatar Aug 14 '19 09:08 DanyHenriquez

Oops, would someone like to contribute a patch? I'll be away from the computer for the next ~6 hours.

mholt avatar Aug 14 '19 11:08 mholt

I found a fix

We used *:80 and other versions of this definition.

Change it to http://*:80. So put the protocol in front of it and caddy will start with version 1.0.2.

This is also in line with the comment attached to the release.

Hope this will help you guys too :)

Thanks for posting this fix. Was running into the same issue here.

# Old naming scheme produces a runtime error on v1.0.2
name.example.com:80 { }
# Fix
http://name.example.com:80 { }

paulgalow avatar Aug 14 '19 12:08 paulgalow

I've added test cases and pushed a fix at a08ab0c - would you please try that and confirm it works for you and then I will tag another release. Thanks

mholt avatar Aug 14 '19 16:08 mholt

I confirm that it is now working correctly. Thanks!

hectorm avatar Aug 14 '19 16:08 hectorm

Caddy v1.0.3 has this fix. Thanks for the report!

mholt avatar Aug 14 '19 20:08 mholt