fullstorydev / grpcurl

Like cURL, but for gRPC: Command-line tool for interacting with gRPC servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SIGSEGV: panic: runtime error: invalid memory address or nil pointer dereference in v1.8.8

mprimeaux opened this issue · comments

I'm using an existing .proto file that been working nicely with grpcurl for the past months. It appears that version 1.8.8 released a few days ago now results in a panic.

I downloaded version 1.8.7 and things work as expected.

❯ cat mutate/challenge.action.add.json | ~/Downloads/grpcurl -plaintext -vv -d @ -format=json -use-reflection=false -proto ../internal/api/hydra_service.proto localhost:50503 api.Hydra.Mutate

Resolved method descriptor:
// Mutates one or more underlying data structures.
rpc Mutate ( .api.MutateRequest ) returns ( .api.MutateResponse );

Request metadata to send:

Response headers received:
content-type: application/grpc

Estimated response size: 50 bytes

Response contents:
{
  "data": [
    {
          "id": "6789a357-0d07-4cf9-8025-2438d7e639f2"
        }
  ]
}

Response trailers received:
(empty)
Sent 1 request and received 1 response

Using version 1.8.8 results in the following panic:

❯ cat mutate/challenge.action.add.json |  -plaintext -vv -d @ -format=json -use-reflection=false -proto ../internal/api/hydra_service.proto localhost:50503 api.Hydra.Mutate
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x100f714e8]

goroutine 1 [running]:
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive({0x101406c80, 0x14000195308}, {0x140001bf8e0, 0x1c}, 0x1400025f608?, 0x100f08bf4?, 0x0?)
	github.com/jhump/protoreflect@v1.15.2/desc/protoparse/parser.go:389 +0x148
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive.func1(0x14000365380, 0x140003b2eb0, 0x140001e3810, {0x101406c80, 0x14000195308}, 0x1013ba560?, 0x140001d9f01?)
	github.com/jhump/protoreflect@v1.15.2/desc/protoparse/parser.go:401 +0x164
github.com/jhump/protoreflect/desc/protoparse.parseToProtoRecursive({0x101406c80, 0x14000195308}, {0x16f76a75a, 0x23}, 0x14000361400?, 0x0?, 0x1400025f7b8?)
	github.com/jhump/protoreflect@v1.15.2/desc/protoparse/parser.go:402 +0x1d8
github.com/jhump/protoreflect/desc/protoparse.parseToProtosRecursive({0x101406c80, 0x14000195308}, {0x140002fed70, 0x1, 0x0?}, 0x0?, 0x0?)
	github.com/jhump/protoreflect@v1.15.2/desc/protoparse/parser.go:365 +0x80
github.com/jhump/protoreflect/desc/protoparse.Parser.ParseFiles({{0x0, 0x0, 0x0}, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, ...}, ...)
	github.com/jhump/protoreflect@v1.15.2/desc/protoparse/parser.go:153 +0x210
github.com/fullstorydev/grpcurl.DescriptorSourceFromProtoFiles({0x0, 0x0, 0x0}, {0x140002fed70?, 0x1400025fb18?, 0x1006a3018?})
	github.com/fullstorydev/grpcurl/desc_source.go:71 +0xbc
main.main()
	github.com/fullstorydev/grpcurl/cmd/grpcurl/grpcurl.go:501 +0xca8

I did notice that version 1.8.8 updated to protoreflect 1.15.2. I figured I'd start here to see if anyone has run into this issue yet before opening an issue over in the other repository.

This is definitely going to be a @jhump question

I suspected based on the stack trace but could have been our use of it. I’ll open an issue in the protoreflect repository and reference this issue.

As another data point, the above failing grpcurl command succeeds if I add -import-path ../internal/api to the command line, which now makes sense based on this line in grpcurl/desc_source.go.

Also, I pulled down the protoreflect code and wrote a new test using the same failing .proto file and it parses it just fine; no SIGSEGV panic.

After further debugging, I was able to simulate the exact panic by setting InferImportPaths to true on the protoparse.Parser.

Now that I have a failing test in protoreflect, I'll move the discussion fully over there.

Sorry for the breakage. This was something that didn't have adequate test coverage in protoreflect and has unfortunately been broken since v1.15.0 (even the first release candidate).

I should have a fix and a new release of protoreflect this week.

This should be fixed as of v1.15.3 of protoreflect. @mprimeaux, could you please verify?

@jhump I compiled grpcurl against protoreflect v1.15.3, tested various scenarios, and can confirm the fix works for this specific issue. Thanks for helping.

@dragonsinth I executed the updatedeps make target for the PR. If you prefer me to only upgrade protoreflect then please let me know. Happy to go that route, also.

Thanks @dragonsinth. Sincerely appreciate your help and support.

I'm not familiar with the process of updating the grpcurl brew formula. Should I open a PR over in this repo.

@mprimeaux I think we'd have to make another point release first to be able to do that

CC: @gpassini who's knowledge of this is fresher (no rush, whenever you're back)

Thanks much. I've got a workaround as stated above so no rush.

Again, appreciate your help and support.

commented

this is pretty confusing to new users. So glad to have a workaround but any timeline on the release?

Sorry for the delay. The version 1.8.9 is now released!
https://github.com/fullstorydev/grpcurl/releases/tag/v1.8.9

Thanks, @gpassini. Will the brew formula also be updated in the near future? Again, thanks for your help.

Yes, I had an issue opening the update PR with Homebrew that I'm looking how to solve. But in the worst case they have some jobs that update formulas automatically. I'd say tomorrow it'll be updated either way.

@mprimeaux here's the PR to update the version in Homebrew: Homebrew/homebrew-core#152288
As soon as it's merged, you'll be able to download the new release directly from Homebrew.