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

null pointer dereference in parser validator #290

Closed
jonlundy opened this issue Aug 14, 2018 · 4 comments
Closed

null pointer dereference in parser validator #290

jonlundy opened this issue Aug 14, 2018 · 4 comments

Comments

@jonlundy
Copy link
Contributor

jonlundy commented Aug 14, 2018

Expected Behaviour

receive an graphQLError result object

Actual Behavior

panic is thrown.

http: panic serving [::1]:64085: runtime error: invalid memory address or nil pointer dereference
goroutine 4285 [running]:
net/http.(*conn).serve.func1(0xc4206c8000)
        /usr/local/Cellar/go/1.10.3/libexec/src/net/http/server.go:1726 +0xd0
panic(0x1607600, 0x1beac80)
        /usr/local/Cellar/go/1.10.3/libexec/src/runtime/panic.go:502 +0x229
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules.(*overlappingFieldsCanBeMergedManager).findConflict(0xc420468300, 0xc42088ea00, 0xc4202a8300, 0xc4202a8400, 0xc4200e8608)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules/overlapping_fields_can_be_merged.go:419 +0x73a
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules.(*overlappingFieldsCanBeMergedManager).collectConflictsBetween(0xc420468300, 0xc420aa9528, 0x1628e00, 0xc420468660, 0xc4204686e0)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules/overlapping_fields_can_be_merged.go:403 +0xc4
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules.(*overlappingFieldsCanBeMergedManager).collectConflictsBetweenFieldsAndFragment(0xc420468300, 0xc420aa9528, 0xc420468600, 0xc420468660, 0xc420520980)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules/overlapping_fields_can_be_merged.go:291 +0x160
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules.(*overlappingFieldsCanBeMergedManager).findConflictsWithinSelectionSet(0xc420468300, 0xc420468220, 0x2, 0x2, 0xc42088e3f0, 0xc420a50050, 0xc42088ea20)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules/overlapping_fields_can_be_merged.go:258 +0x1b2
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules.init.11.func1.2(0xc420520bc0, 0xc4202a8280)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/rules/overlapping_fields_can_be_merged.go:87 +0x7c
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator.(*Walker).walkSelection(0xc420520bc0, 0xc4201bc8f0, 0x172ee40, 0xc4202a8280)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/walk.go:243 +0x26a
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator.(*Walker).walkSelectionSet(0xc420520bc0, 0xc4201bc8f0, 0xc4207af620, 0x1, 0x1)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/walk.go:205 +0x59
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator.(*Walker).walkOperation(0xc420520bc0, 0xc42066a3f0)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/walk.go:110 +0x2d7
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator.(*Walker).walk(0xc420520bc0)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/walk.go:69 +0x52
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator.Walk(0xc4201cdec0, 0xc420520840, 0xc42035e0c0)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/walk.go:53 +0xa6
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator.Validate(0xc4201cdec0, 0xc420520840, 0x0, 0x16bd5aa, 0xc)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/validator/validator.go:42 +0x181
github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser.LoadQuery(0xc4201cdec0, 0xc4206ad880, 0x314, 0x16c00e2, 0x10, 0x0, 0x168b9c0)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/vektah/gqlparser/gqlparser.go:28 +0xe7
github.rakops.com/prospecting/prospr-api/vendor/github.com/99designs/gqlgen/handler.GraphQL.func1(0x1731c80, 0xc420232460, 0xc420136700)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/99designs/gqlgen/handler/graphql.go:160 +0x267
net/http.HandlerFunc.ServeHTTP(0xc4204681c0, 0x1731c80, 0xc420232460, 0xc420136700)
        /usr/local/Cellar/go/1.10.3/libexec/src/net/http/server.go:1947 +0x44
net/http.StripPrefix.func1(0x1731c80, 0xc420232460, 0xc420136600)
        /usr/local/Cellar/go/1.10.3/libexec/src/net/http/server.go:1986 +0x19a
net/http.HandlerFunc.ServeHTTP(0xc42088e360, 0x1731c80, 0xc420232460, 0xc420136600)
        /usr/local/Cellar/go/1.10.3/libexec/src/net/http/server.go:1947 +0x44
github.rakops.com/prospecting/prospr-api/internal/routes.getQuery(0x1731c80, 0xc420232460, 0xc420520500, 0xc420136600, 0x1734860, 0xc42088e300)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/internal/routes/graphql.go:37 +0x1cc
github.rakops.com/prospecting/prospr-api/vendor/sour.is/x/toolbox/httpsrv.HandlerFunc.ServeHTTP(0x16e2bc8, 0x1731c80, 0xc420232460, 0xc420520500, 0xc420136500, 0x1734860, 0xc42088e300)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/sour.is/x/toolbox/httpsrv/routes_ident.go:33 +0x173
github.rakops.com/prospecting/prospr-api/vendor/sour.is/x/toolbox/httpsrv.identWrapper.func1(0x1731c80, 0xc420232460, 0xc420136500)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/sour.is/x/toolbox/httpsrv/wrappers.go:23 +0x484
net/http.HandlerFunc.ServeHTTP(0xc4203009a0, 0x1731c80, 0xc420232460, 0xc420136500)
        /usr/local/Cellar/go/1.10.3/libexec/src/net/http/server.go:1947 +0x44
github.rakops.com/prospecting/prospr-api/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc42020ecb0, 0x1731c80, 0xc420232460, 0xc420136500)
        /Users/jonlundy/Documents/go/src/github.rakops.com/prospecting/prospr-api/vendor/github.com/gorilla/mux/mux.go:162 +0xed
net/http.serverHandler.ServeHTTP(0xc4202091e0, 0x1731c80, 0xc420232460, 0xc420596100)
        /usr/local/Cellar/go/1.10.3/libexec/src/net/http/server.go:2694 +0xbc
net/http.(*conn).serve(0xc4206c8000, 0x1732180, 0xc4201c6040)
        /usr/local/Cellar/go/1.10.3/libexec/src/net/http/server.go:1830 +0x651
created by net/http.(*Server).Serve
        /usr/local/Cellar/go/1.10.3/libexec/src/net/http/server.go:2795 +0x27b

Minimal graphql.schema and models to reproduce

query panic{
  panic{  
    ...PanicInput
    __typename
  }
}
fragment PanicInput on Panic {
  __typename
}
@JulienBreux
Copy link

I have a same think like this :

2018/08/14 23:21:54 http: panic serving 127.0.0.1:55791: reflect: call of reflect.Value.Type on zero Value
goroutine 451 [running]:
net/http.(*conn).serve.func1(0xc42026d220)
	/usr/local/Cellar/go/1.10.3/libexec/src/net/http/server.go:1726 +0xd0
panic(0x16e5640, 0xc4204ecf20)
	/usr/local/Cellar/go/1.10.3/libexec/src/runtime/panic.go:502 +0x229
reflect.Value.Type(0x0, 0x0, 0x0, 0x6, 0xc4202603c8)
	/usr/local/Cellar/go/1.10.3/libexec/src/reflect/value.go:1713 +0x16d
github.com/seize/service-gateway/vendor/github.com/vektah/gqlparser/validator.(*varValidator).validateVarType(0xc42030f898, 0xc4203dcb70, 0x0, 0x0, 0x0, 0x1)
	/Users/jbx/go/src/github.com/seize/service-gateway/vendor/github.com/vektah/gqlparser/validator/vars.go:112 +0x97a
github.com/seize/service-gateway/vendor/github.com/vektah/gqlparser/validator.VariableValues(0xc42024ee40, 0xc4203f27e0, 0xc4203dc990, 0xc420294810, 0xd)
	/Users/jbx/go/src/github.com/seize/service-gateway/vendor/github.com/vektah/gqlparser/validator/vars.go:54 +0x2e4
github.com/seize/service-gateway/vendor/github.com/99designs/gqlgen/handler.GraphQL.func1(0x1856de0, 0xc4204ea700, 0xc4200c3400)
	/Users/jbx/go/src/github.com/seize/service-gateway/vendor/github.com/99designs/gqlgen/handler/graphql.go:172 +0x31d

@JulienBreux
Copy link

Related to?
https://github.com/vektah/gqlparser/pulls

@jonlundy
Copy link
Contributor Author

jonlundy commented Aug 15, 2018

@JulienBreux that seems to be throwing in a different place. What are the steps to reproduce? maybe it would be better in a separate issue.

@vektah
Copy link
Collaborator

vektah commented Aug 23, 2018

Fixed in vektah/gqlparser#64

@vektah vektah closed this as completed Aug 23, 2018
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

3 participants