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

Method call with expired context causes nil-pointer panic #271

Closed
lthibault opened this issue Jul 29, 2022 · 0 comments
Closed

Method call with expired context causes nil-pointer panic #271

lthibault opened this issue Jul 29, 2022 · 0 comments
Labels

Comments

@lthibault
Copy link
Collaborator

To reproduce: run TestHandleReturn_regression in level0_test.go, under the bug/bootstrap-panic branch.

func TestPanic(t *testing.T) {
	p1, p2 := transport.NewPipe(1)

	srv := testcp.PingPong_ServerToClient(pingPongServer{}, nil)
	conn1 := rpc.NewConn(rpc.NewTransport(p2), &rpc.Options{
		BootstrapClient: srv.Client,
	})
	defer conn1.Close()

	conn2 := rpc.NewConn(rpc.NewTransport(p1), nil)
	defer conn2.Close()

	pp := testcp.PingPong{Client: conn2.Bootstrap(context.Background())}
	defer pp.Release()

	// create an EXPIRED context
	ctx, cancel := context.WithCancel(context.Background())
	cancel()

	f, release := pp.EchoNum(ctx, func(ps testcp.PingPong_echoNum_Params) error {
		ps.SetN(42)
		return nil
	})
	defer release()

	_, err := f.Struct()  // BANG!
	assert.NoError(t, err)
}
panic: Promise.Fulfill called after Fulfill or Reject

goroutine 15 [running]:
capnproto.org/go/capnp/v3.(*Promise).Fulfill(0x0?, {0xc000132570, 0x0, 0x0, {0x0, 0x0}, 0x0, 0x80})
	/Users/lthibault/Go/src/capnproto.org/go/capnp/answer.go:132 +0x135
capnproto.org/go/capnp/v3/rpc.(*Conn).handleReturn.func2.2()
	/Users/lthibault/Go/src/capnproto.org/go/capnp/rpc/rpc.go:952 +0x53
capnproto.org/go/capnp/v3/internal/syncutil.Without({0x12f3fb0, 0xc000120cd8}, 0xc000049f60)
	/Users/lthibault/Go/src/capnproto.org/go/capnp/internal/syncutil/with.go:19 +0x8c
capnproto.org/go/capnp/v3/rpc.(*Conn).handleReturn.func2()
	/Users/lthibault/Go/src/capnproto.org/go/capnp/rpc/rpc.go:951 +0x21e
created by capnproto.org/go/capnp/v3/rpc.(*Conn).handleReturn
	/Users/lthibault/Go/src/capnproto.org/go/capnp/rpc/rpc.go:947 +0x697
FAIL	capnproto.org/go/capnp/v3/rpc	0.198s
FAIL
@lthibault lthibault added the bug label Jul 29, 2022
zenhack added a commit to zenhack/go-capnp that referenced this issue Aug 8, 2022
@zenhack zenhack mentioned this issue Aug 8, 2022
lthibault added a commit that referenced this issue Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant