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
To reproduce: run
TestHandleReturn_regressioninlevel0_test.go, under thebug/bootstrap-panicbranch.