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

GRPC reflection will crash when there is no package specifier defined #3222

Closed
tmulkern opened this issue Jul 21, 2023 · 1 comment · Fixed by #3338
Closed

GRPC reflection will crash when there is no package specifier defined #3222

tmulkern opened this issue Jul 21, 2023 · 1 comment · Fixed by #3338
Assignees
Labels

Comments

@tmulkern
Copy link

tmulkern commented Jul 21, 2023

Brief summary

If the proto files used in a GRPC omits the package specifier and the k6 GRPC client uses reflection, it will result in a error

ERRO[0002] panic: runtime error: invalid memory address or nil pointer dereference

The package specifier is optional as per the proto spec so the reflection should not result in an error

k6 version

0.45

OS

All

Docker version and image (if applicable)

No response

Steps to reproduce the problem

  1. Use the following proto specfication (please take note that there is no package specifier)
// based on https://grpc.io/docs/guides/concepts.html

syntax = "proto2";

service HelloService {
  rpc SayHello(HelloRequest) returns (HelloResponse);
  rpc LotsOfReplies(HelloRequest) returns (stream HelloResponse);
  rpc LotsOfGreetings(stream HelloRequest) returns (HelloResponse);
  rpc BidiHello(stream HelloRequest) returns (stream HelloResponse);
}

message HelloRequest {
  optional string greeting = 1;
}

message HelloResponse {
  required string reply = 1;
}
  1. Use this proto to host a GRPC service
  2. Connect to the GRPC service using the GRPC client in K6 with relection enabled

Expected behaviour

No Error

Actual behaviour

Error produced

ERRO[0002] panic: runtime error: invalid memory address or nil pointer dereference
goroutine 108 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x65
go.k6.io/k6/js/common.RunWithPanicCatching.func1()
        go.k6.io/k6@v0.45.0/js/common/util.go:82 +0x1f3
panic({0x1976e80, 0x2d12a50})
        runtime/panic.go:884 +0x213
github.com/dop251/goja.(*Runtime).runWrapped.func1()
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/runtime.go:2516 +0x185
panic({0x1976e80, 0x2d12a50})
        runtime/panic.go:884 +0x213
github.com/dop251/goja.(*vm).handleThrow(0xc000c9c480, {0x1976e80, 0x2d12a50})
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/vm.go:788 +0x497
github.com/dop251/goja.(*vm).try.func1()
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/vm.go:807 +0x45
panic({0x1976e80, 0x2d12a50})
        runtime/panic.go:884 +0x213
github.com/dop251/goja.(*vm).handleThrow(0xc000c9c480, {0x1976e80, 0x2d12a50})
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/vm.go:788 +0x497
github.com/dop251/goja.(*vm).runTryInner.func1()
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/vm.go:830 +0x45
panic({0x1976e80, 0x2d12a50})
        runtime/panic.go:884 +0x213
go.k6.io/k6/lib/netext/grpcext.(*reflectionClient).resolveServiceFileDescriptors(0x7ffadc4d8f70?, {0x7ffadc4d8f70, 0xc0031b2330}, 0x0?)
        go.k6.io/k6@v0.45.0/lib/netext/grpcext/reflect.go:71 +0x3d5
go.k6.io/k6/lib/netext/grpcext.(*reflectionClient).Reflect(0xc0034d47d0, {0x1f551c0?, 0xc000cfccf0?})
        go.k6.io/k6@v0.45.0/lib/netext/grpcext/reflect.go:37 +0x1d9
go.k6.io/k6/lib/netext/grpcext.(*Conn).Reflect(0x1f551c0?, {0x1f551c0, 0xc000cfccf0})
        go.k6.io/k6@v0.45.0/lib/netext/grpcext/conn.go:86 +0x5c
go.k6.io/k6/js/modules/k6/grpc.(*Client).Connect(0xc000cf3500, {0xc002198300, 0x3a}, 0x4798d9?)
        go.k6.io/k6@v0.45.0/js/modules/k6/grpc/client.go:161 +0x914
reflect.Value.call({0x1ab13a0?, 0xc000cf3500?, 0x7ffadc249b78?}, {0x1bd2227, 0x4}, {0xc000cfcc00, 0x2, 0xc002702340?})
        reflect/value.go:586 +0xb0b
reflect.Value.Call({0x1ab13a0?, 0xc000cf3500?, 0xc000cfcba0?}, {0xc000cfcc00?, 0xc0013943d0?, 0x0?})
        reflect/value.go:370 +0xbc
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1({{0x1f6db50, 0xc000cf3530}, {0xc000ce64e0, 0x2, 0x6}})
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/runtime.go:2056 +0x3dc
github.com/dop251/goja.(*nativeFuncObject).vmCall(0xc000ce63c0, 0xc000c9c480, 0x2)
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/func.go:559 +0x1af
github.com/dop251/goja.call.exec(0x7?, 0xc000c9c480)
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/vm.go:3366 +0x6a
github.com/dop251/goja.(*vm).run(0xc000c9c480)
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/vm.go:582 +0x62
github.com/dop251/goja.(*vm).runTryInner(0xc000c9c480?)
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/vm.go:834 +0x70
github.com/dop251/goja.(*baseJsFuncObject).__call(0xc000ce50a0, {0xc000cdf9c0?, 0x1, 0x0?}, {0x0?, 0x0}, {0x0?, 0x0?})
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/func.go:426 +0x705
github.com/dop251/goja.(*baseJsFuncObject)._call(...)
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/func.go:442
github.com/dop251/goja.(*arrowFuncObject).Call(0x425cba?, {{0x1f6e4d0, 0x2fa0ec0}, {0xc000cdf9c0, 0x1, 0x1}})
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/func.go:386 +0x57
github.com/dop251/goja.AssertFunction.func1.1()
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/runtime.go:2476 +0x77
github.com/dop251/goja.(*vm).try(0xc000c9c480, 0xc000cb76f0)
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/vm.go:811 +0x244
github.com/dop251/goja.(*Runtime).runWrapped(0xc000100c00, 0x7ffb039f5d28?)
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/runtime.go:2520 +0x7c
github.com/dop251/goja.AssertFunction.func1({0x1f6e4d0?, 0x2fa0ec0?}, {0xc000cdf9c0?, 0x1?, 0x1?})
        github.com/dop251/goja@v0.0.0-20230531210528-d7324b2d74f7/runtime.go:2475 +0x92
go.k6.io/k6/js.(*VU).runFn.func2.1()
        go.k6.io/k6@v0.45.0/js/runner.go:826 +0x44
go.k6.io/k6/js/eventloop.(*EventLoop).Start(0xc000c90780, 0xc000cfca20)
        go.k6.io/k6@v0.45.0/js/eventloop/eventloop.go:177 +0x1bd
go.k6.io/k6/js.(*VU).runFn.func2()
        go.k6.io/k6@v0.45.0/js/runner.go:825 +0xea
go.k6.io/k6/js/common.RunWithPanicCatching({0x1f73140?, 0xc000463700?}, 0x41eb47?, 0x30?)
        go.k6.io/k6@v0.45.0/js/common/util.go:86 +0x87
go.k6.io/k6/js.(*VU).runFn(0xc000cf6b40, {0x1f55150, 0xc000c91c20}, 0x0?, 0xc0025fc978, 0xc000cdf9b0, {0xc000cdf9c0, 0x1, 0x1})
        go.k6.io/k6@v0.45.0/js/runner.go:824 +0x28a
go.k6.io/k6/js.(*ActiveVU).RunOnce(0xc0009e2e80)
        go.k6.io/k6@v0.45.0/js/runner.go:769 +0x3ef
go.k6.io/k6/lib/executor.getIterationRunner.func1({0x1f551f8, 0xc000cfc870}, {0x1f47080?, 0xc0009e2e80?})
        go.k6.io/k6@v0.45.0/lib/executor/helpers.go:81 +0x64
go.k6.io/k6/lib/executor.SharedIterations.Run.func6({0x1f4ef20, 0xc000cf6b40})
        go.k6.io/k6@v0.45.0/lib/executor/shared_iterations.go:259 +0x366
created by go.k6.io/k6/lib/executor.SharedIterations.Run
        go.k6.io/k6@v0.45.0/lib/executor/shared_iterations.go:271 +0xbde
@tmulkern
Copy link
Author

I am currently writing a PR to fix this

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 a pull request may close this issue.

2 participants