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

Fix bug in logql parsing that leads to crash. #2046

Merged
merged 2 commits into from
May 6, 2020

Conversation

gouthamve
Copy link
Member

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x20ae356]
goroutine 39530021 [running]:
github.com/grafana/loki/pkg/logql.andFilter.Filter(0x0, 0x0, 0x3beffc0, 0xc01f065bc0, 0xc01aaaec00, 0x13d, 0x200, 0xffffffffffffffff)
	/src/loki/pkg/logql/filter.go:66 +0x26
github.com/grafana/loki/pkg/chunkenc.(*bufferedIterator).Next(0xc00a48fba0, 0x0)
	/src/loki/pkg/chunkenc/memchunk.go:616 +0x1cb
github.com/grafana/loki/pkg/iter.(*nonOverlappingIterator).Next(0xc00130ae40, 0x0)
	/src/loki/pkg/iter/iterator.go:438 +0x135
github.com/grafana/loki/pkg/iter.(*timeRangedIterator).Next(0xc00130ae80, 0x0)
	/src/loki/pkg/iter/iterator.go:497 +0x48
github.com/grafana/loki/pkg/iter.(*reverseIterator).load(0xc00072ac40)
	/src/loki/pkg/iter/iterator.go:555 +0x70
github.com/grafana/loki/pkg/iter.(*reverseIterator).Next(0xc00072ac40, 0x0)
	/src/loki/pkg/iter/iterator.go:563 +0x2f
github.com/grafana/loki/pkg/iter.(*nonOverlappingIterator).Next(0xc00130af40, 0x10)
	/src/loki/pkg/iter/iterator.go:438 +0x135

This is caused by people doing |= "" which would result in parsing of
TrueFilter but would be returned as nil.

Tests are pending

Signed-off-by: Goutham Veeramachaneni gouthamve@gmail.com

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x20ae356]
goroutine 39530021 [running]:
github.com/grafana/loki/pkg/logql.andFilter.Filter(0x0, 0x0, 0x3beffc0, 0xc01f065bc0, 0xc01aaaec00, 0x13d, 0x200, 0xffffffffffffffff)
	/src/loki/pkg/logql/filter.go:66 +0x26
github.com/grafana/loki/pkg/chunkenc.(*bufferedIterator).Next(0xc00a48fba0, 0x0)
	/src/loki/pkg/chunkenc/memchunk.go:616 +0x1cb
github.com/grafana/loki/pkg/iter.(*nonOverlappingIterator).Next(0xc00130ae40, 0x0)
	/src/loki/pkg/iter/iterator.go:438 +0x135
github.com/grafana/loki/pkg/iter.(*timeRangedIterator).Next(0xc00130ae80, 0x0)
	/src/loki/pkg/iter/iterator.go:497 +0x48
github.com/grafana/loki/pkg/iter.(*reverseIterator).load(0xc00072ac40)
	/src/loki/pkg/iter/iterator.go:555 +0x70
github.com/grafana/loki/pkg/iter.(*reverseIterator).Next(0xc00072ac40, 0x0)
	/src/loki/pkg/iter/iterator.go:563 +0x2f
github.com/grafana/loki/pkg/iter.(*nonOverlappingIterator).Next(0xc00130af40, 0x10)
	/src/loki/pkg/iter/iterator.go:438 +0x135
```

This is caused by people doing `|= ""` which would result in parsing of
TrueFilter but would be returned as nil.

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
@pull-request-size pull-request-size bot added size/M and removed size/S labels May 6, 2020
@cyriltovena cyriltovena merged commit 06b5059 into grafana:master May 6, 2020
rfratto pushed a commit that referenced this pull request May 6, 2020
* Fix bug in logql parsing that leads to crash.

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x20ae356]
goroutine 39530021 [running]:
github.com/grafana/loki/pkg/logql.andFilter.Filter(0x0, 0x0, 0x3beffc0, 0xc01f065bc0, 0xc01aaaec00, 0x13d, 0x200, 0xffffffffffffffff)
	/src/loki/pkg/logql/filter.go:66 +0x26
github.com/grafana/loki/pkg/chunkenc.(*bufferedIterator).Next(0xc00a48fba0, 0x0)
	/src/loki/pkg/chunkenc/memchunk.go:616 +0x1cb
github.com/grafana/loki/pkg/iter.(*nonOverlappingIterator).Next(0xc00130ae40, 0x0)
	/src/loki/pkg/iter/iterator.go:438 +0x135
github.com/grafana/loki/pkg/iter.(*timeRangedIterator).Next(0xc00130ae80, 0x0)
	/src/loki/pkg/iter/iterator.go:497 +0x48
github.com/grafana/loki/pkg/iter.(*reverseIterator).load(0xc00072ac40)
	/src/loki/pkg/iter/iterator.go:555 +0x70
github.com/grafana/loki/pkg/iter.(*reverseIterator).Next(0xc00072ac40, 0x0)
	/src/loki/pkg/iter/iterator.go:563 +0x2f
github.com/grafana/loki/pkg/iter.(*nonOverlappingIterator).Next(0xc00130af40, 0x10)
	/src/loki/pkg/iter/iterator.go:438 +0x135
```

This is caused by people doing `|= ""` which would result in parsing of
TrueFilter but would be returned as nil.

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>

* Add tests for the panic

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
@gouthamve gouthamve deleted the fix-panic-loql branch May 7, 2020 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants