Skip to content

fillGroupedVars: runtime error: invalid memory address or nil pointer dereference #3768

@d4l3k

Description

@d4l3k

If you suspect this could be a bug, follow the template.

  • What version of Dgraph are you using?
    Dgraph version : v1.0.16
    Commit SHA-1 : 0590ee9
    Commit timestamp : 2019-07-11 11:52:54 -0700
    Branch : HEAD
    Go version : go1.12.5

  • Have you tried reproducing the issue with latest release?
    Yes

  • What is the hardware spec (RAM, OS)?
    32GB RAM, Arch Linux, running in docker compose

  • Steps to reproduce the issue (command/config used to run Dgraph).
    Run query

		resp, err := s.dgo.NewReadOnlyTxn().BestEffort().QueryWithVars(ctx,
			`query recs($url: string) {
				docs(func: eq(url, $url)) {
					url
					title
					desc
				}

				var(func: eq(url, $url)) @ignorereflex {
					~likes {
						likes {
							uids as uid
						}
					}
				}

				var(func: uid(uids)) @groupby(uid) {
					counts as count(uid)
				}

				recs(func: uid(counts)) {
					count: val(counts)
					url
					title
					desc
				}
			}
		`,
			map[string]string{"$url": url},
		)

schema

<author>: uid @reverse .
<chapters>: int .
<complete>: bool .
<created>: string .
<desc>: string .
<image>: string .
<likecount>: int .
<likes>: uid @count @reverse .
<name>: string .
<reviews>: int .
<tags>: [string] .
<title>: string .
<updated>: string .
<url>: string @index(hash) @upsert .
<urls>: [string] .
<username>: string @index(hash) @upsert .
<wordcount>: int .
  • Expected behaviour and actual result.

It returns the results.

Instead it crashes the server with error:

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

goroutine 577 [running]:
github.com/dgraph-io/dgraph/query.(*SubGraph).fillGroupedVars(0xc0482d1600, 0xc0482ce120, 0xc01a658000, 0x0, 0x1, 0xc01a658008, 0x0)
        /tmp/go/src/github.com/dgraph-io/dgraph/query/groupby.go:298 +0x223
github.com/dgraph-io/dgraph/query.(*SubGraph).processGroupBy(0xc0482d1600, 0xc0482ce120, 0xc01a658000, 0x0, 0x1, 0x1f86470, 0xc002abf6b8)
        /tmp/go/src/github.com/dgraph-io/dgraph/query/groupby.go:383 +0x1a7
github.com/dgraph-io/dgraph/query.(*SubGraph).valueVarAggregation(0xc0482d1600, 0xc0482ce120, 0xc01a658000, 0x0, 0x1, 0x0, 0x0, 0x0)
        /tmp/go/src/github.com/dgraph-io/dgraph/query/query.go:1196 +0xdb2
github.com/dgraph-io/dgraph/query.(*SubGraph).populatePostAggregation(0xc0482d1600, 0xc0482ce120, 0xc01a658000, 0x1, 0x1, 0x0, 0x0, 0x1)
        /tmp/go/src/github.com/dgraph-io/dgraph/query/query.go:1295 +0x19d
github.com/dgraph-io/dgraph/query.(*QueryRequest).ProcessQuery(0xc002abfb30, 0x16f1340, 0xc00049ba40, 0x1, 0x1)
        /tmp/go/src/github.com/dgraph-io/dgraph/query/query.go:2582 +0xd2b
github.com/dgraph-io/dgraph/query.(*QueryRequest).Process(0xc002abfb30, 0x16f1340, 0xc00049ba40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /tmp/go/src/github.com/dgraph-io/dgraph/query/query.go:2628 +0x5e
github.com/dgraph-io/dgraph/edgraph.(*Server).Query(0x1f86470, 0x16f1340, 0xc00049ba40, 0xc051a71bd0, 0xc001d01aa0, 0x0, 0x0)
        /tmp/go/src/github.com/dgraph-io/dgraph/edgraph/server.go:516 +0x61b
github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/dgo/protos/api._Dgraph_Query_Handler(0x14838c0, 0x1f86470, 0x16f1340, 0xc00049b8c0, 0xc0003c18f0, 0x0, 0x16f1340, 0xc00049b8c0, 0xc0002d2a00, 0xc064d1cc78)
        /tmp/go/src/github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/dgo/protos/api/api.pb.go:1757 +0x23e
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000402000, 0x16fdd40, 0xc0482aa000, 0xc0002d2a00, 0xc051ac01e0, 0x1ebd778, 0x0, 0x0, 0x0)
        /tmp/go/src/google.golang.org/grpc/server.go:1011 +0x4c3
google.golang.org/grpc.(*Server).handleStream(0xc000402000, 0x16fdd40, 0xc0482aa000, 0xc0002d2a00, 0x0)
        /tmp/go/src/google.golang.org/grpc/server.go:1249 +0x12b5
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0482592b0, 0xc000402000, 0x16fdd40, 0xc0482aa000, 0xc0002d2a00)
        /tmp/go/src/google.golang.org/grpc/server.go:680 +0x9f
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /tmp/go/src/google.golang.org/grpc/server.go:678 +0xa1

Metadata

Metadata

Assignees

Labels

area/querylang/groupbyIssues related to the @groupby directive.kind/bugSomething is broken.priority/P0Critical issue that requires immediate attention.status/acceptedWe accept to investigate/work on it.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions