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
api/v1 test sometimes makes parser panic #7131
Comments
cc @slrtbtfs The input that creates the panic is "123". |
That is probably a race between the recover() and the end of the test? |
New hypothesis: It's because the parser struct is being reused to save allocations. At prometheus/promql/parser/parse.go Lines 166 to 179 in 5ab6b04
generatedParserResult field is not reset to nil and the old data lying around can mess up the parser error handling.
It should only cause problems in case the parser fails, though. This likely is the cause of both this issue and #7127. |
Indeed, this patch fixes it: From 5afa6bc2069fb43234954514453d2d46c35b1008 Mon Sep 17 00:00:00 2001
From: Julien Pivotto <roidelapluie@inuits.eu>
Date: Thu, 16 Apr 2020 01:44:43 +0200
Subject: [PATCH] Cleanup generatedParserResult
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
---
promql/parser/parse.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/promql/parser/parse.go b/promql/parser/parse.go
index 1cdfd75da..3d5ebed4b 100644
--- a/promql/parser/parse.go
+++ b/promql/parser/parse.go
@@ -168,6 +168,7 @@ func newParser(input string) *parser {
p.injecting = false
p.parseErrors = nil
+ p.generatedParserResult = nil
// Clear lexer struct before reusing.
p.lex = Lexer{
--
2.22.0 |
Reusing the same generatedParserResult ends up in strange panics: See prometheus#7131 and prometheus#7127. Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
closed by #7132 |
Reusing the same generatedParserResult ends up in strange panics: See prometheus#7131 and prometheus#7127. Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
What did you do?
Run go test 5 times in github.com/prometheus/prometheus/web/api/v1
What did you expect to see?
ok five times
What did you see instead? Under which circumstances?
ok five times but 2 times with a panic
Environment
System information:
Linux
Prometheus version:
master
Logs:
The text was updated successfully, but these errors were encountered: