-
Notifications
You must be signed in to change notification settings - Fork 173
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
SIGSEGV: panic: runtime error: invalid memory address or nil pointer dereference in v1.15.2 #572
Comments
As an update, I pulled down the After further debugging, I was able to trip the exact panic by setting Also, I updated the related |
I believe the fix is to the function func parseToProtoRecursive(res protocompile.Resolver, filename string, rep *reporter.Handler, srcPosAddr *SourcePos, results map[string]parser.Result) {
if _, ok := results[filename]; ok {
// already processed this one
return
}
results[filename] = nil // placeholder entry
astRoot, parseResult, _ := parseToAST(res, filename, rep)
if rep.ReporterError() != nil {
return
}
if parseResult == nil {
parseResult, _ = parser.ResultFromAST(astRoot, true, rep)
if rep.ReporterError() != nil {
return
}
}
results[filename] = parseResult
+ if astRoot == nil {
+ return
+ }
for _, decl := range astRoot.Decls {
imp, ok := decl.(*ast2.ImportNode)
if !ok {
continue
}
func() {
orig := *srcPosAddr
*srcPosAddr = astRoot.NodeInfo(imp.Name).Start()
defer func() {
*srcPosAddr = orig
}()
parseToProtoRecursive(res, imp.Name.AsString(), rep, srcPosAddr, results)
}()
if rep.ReporterError() != nil {
return
}
}
} |
Looks like the panic is triggered when an import line is encountered in the syntax = "proto3";
import "google/protobuf/struct.proto"; To reproduce this, I modified the existing test named The After I add the nil check as in my previous comment the failing test passes. I'll leave this here until @jhump or another maintainer has an opportunity to review. I still think the |
@mprimeaux are you willing to submit a PR for the issue as you already do have the code ready!? We are hitting the same issue in Telegraf... |
@srebhan Sure. I'll submit a PR shortly. |
@mprimeaux, I'm working on it. Just checking for a nil AST isn't quite enough. A better fix will handle a lack of AST by using the descriptor in the parse result to recursively crawl through imports. I also realized that the |
@jhump Sounds great and thanks for your help. Shall I just cancel my PR since you're got a handle on it? |
Fixed in #575. |
I've opened up
grpcurl
issue 414, which was recently released with support forprotoreflect
1.15.2.It appears a defect was introduced in
protoreflect
version1.5.2
resulting in the following panic:The previous version of
protoreflect
processed the same.proto
file successfully.I'll see if I can find time to debug but before I do, I wanted to get this in front of folks who know the
protoreflect
code base better than I do at this juncture.Your help and insights are greatly appreciated.
The text was updated successfully, but these errors were encountered: