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

[bug] Panic on HEAD request to parameterised queries #22

Closed
knadh opened this issue Dec 19, 2016 · 2 comments
Closed

[bug] Panic on HEAD request to parameterised queries #22

knadh opened this issue Dec 19, 2016 · 2 comments

Comments

@knadh
Copy link

knadh commented Dec 19, 2016

Run this hello world snippet

package main

import (
	"fmt"
	"log"

	"github.com/buaazp/fasthttprouter"
	"github.com/valyala/fasthttp"
)

func Hello(ctx *fasthttp.RequestCtx) {
	fmt.Fprintf(ctx, "hello, %s!\n", ctx.UserValue("name"))
}

func main() {
	router := fasthttprouter.New()
	router.GET("/hello/:name", Hello)

	log.Fatal(fasthttp.ListenAndServe(":8080", router.Handler))
}

Send a HEAD request

$ curl -I http://localhost:8080/hello/test                                                         47ms 
curl: (52) Empty reply from server

Results in:

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

goroutine 34 [running]:
panic(0x634b40, 0xc42000c100)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/valyala/fasthttp.(*RequestCtx).SetUserValue(0x0, 0x67ee99, 0x4, 0x621d40, 0xc4201280d0)
	/home/kailash/code/go/src/github.com/valyala/fasthttp/server.go:461 +0x22
github.com/buaazp/fasthttprouter.(*node).getValue(0xc420018780, 0xc4201280c7, 0x4, 0x0, 0xc4201182f8, 0xfe5)
	/home/kailash/code/go/src/github.com/buaazp/fasthttprouter/tree.go:364 +0x1c7
github.com/buaazp/fasthttprouter.(*Router).allowed(0xc420013200, 0xc4201280c0, 0xb, 0xc42003ac98, 0x4, 0x4, 0x59)
	/home/kailash/code/go/src/github.com/buaazp/fasthttprouter/router.go:273 +0x13d
github.com/buaazp/fasthttprouter.(*Router).Handler(0xc420013200, 0xc420138000)
	/home/kailash/code/go/src/github.com/buaazp/fasthttprouter/router.go:353 +0x23e
github.com/buaazp/fasthttprouter.(*Router).Handler-fm(0xc420138000)
	/home/kailash/Desktop/fast.go:19 +0x34
github.com/valyala/fasthttp.(*Server).serveConn(0xc4200983c0, 0x794040, 0xc420132000, 0x1, 0x101)
	/home/kailash/code/go/src/github.com/valyala/fasthttp/server.go:1536 +0x573
github.com/valyala/fasthttp.(*Server).(github.com/valyala/fasthttp.serveConn)-fm(0x794040, 0xc420132000, 0xc420120758, 0x1)
	/home/kailash/code/go/src/github.com/valyala/fasthttp/server.go:1250 +0x3e
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc420092480, 0xc42012a100)
	/home/kailash/code/go/src/github.com/valyala/fasthttp/workerpool.go:210 +0xde
github.com/valyala/fasthttp.(*workerPool).getCh.func1(0xc420092480, 0xc42012a100, 0x616480, 0xc42012a100)
	/home/kailash/code/go/src/github.com/valyala/fasthttp/workerpool.go:182 +0x35
created by github.com/valyala/fasthttp.(*workerPool).getCh
	/home/kailash/code/go/src/github.com/valyala/fasthttp/workerpool.go:184 +0x111
exit status 2
@buaazp
Copy link
Owner

buaazp commented Dec 19, 2016

Dup bug with #15

Fixed if you pull the latest code in master.

curl -I http://localhost:8080/hello/test
HTTP/1.1 405 Method Not Allowed
Server: fasthttp
Date: Mon, 19 Dec 2016 14:28:53 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 18
Allow: GET, OPTIONS

@knadh
Copy link
Author

knadh commented Dec 20, 2016

Yep, it's resolved.

@knadh knadh closed this as completed Dec 20, 2016
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

No branches or pull requests

2 participants