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

race condition when stream.Read and CancelRead are called concurrently #3239

Closed
marten-seemann opened this issue Jul 28, 2021 · 0 comments · Fixed by #3241
Closed

race condition when stream.Read and CancelRead are called concurrently #3239

marten-seemann opened this issue Jul 28, 2021 · 0 comments · Fixed by #3241
Labels

Comments

@marten-seemann
Copy link
Member

=== RUN   TestProtoDowngrade
  ==================
  WARNING: DATA RACE
  Write at 0x00c0000f64f0 by goroutine 48:
    github.com/lucas-clemente/quic-go/internal/flowcontrol.(*baseFlowController).addBytesRead()
        /home/runner/go/pkg/mod/github.com/lucas-clemente/[email protected]/internal/flowcontrol/base_flow_controller.go:71 +0xa4
    github.com/lucas-clemente/quic-go/internal/flowcontrol.(*streamFlowController).AddBytesRead()
        /home/runner/go/pkg/mod/github.com/lucas-clemente/[email protected]/internal/flowcontrol/stream_flow_controller.go:90 +0x48
    github.com/lucas-clemente/quic-go.(*receiveStream).readImpl()
        /home/runner/go/pkg/mod/github.com/lucas-clemente/[email protected]/receive_stream.go:177 +0x8a1
    github.com/lucas-clemente/quic-go.(*receiveStream).Read()
        /home/runner/go/pkg/mod/github.com/lucas-clemente/[email protected]/receive_stream.go:84 +0x7c
    github.com/lucas-clemente/quic-go.(*stream).Read()
        <autogenerated>:1 +0x69
    github.com/libp2p/go-libp2p-quic-transport.(*stream).Read()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/stream.go:18 +0x72
    github.com/libp2p/go-libp2p-swarm.(*Stream).Read()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/swarm_stream.go:57 +0x9c
    github.com/multiformats/go-multistream.(*byteReader).ReadByte()
        /home/runner/go/pkg/mod/github.com/multiformats/[email protected]/multistream.go:471 +0x9b
    github.com/multiformats/go-varint.ReadUvarint()
        /home/runner/go/pkg/mod/github.com/multiformats/[email protected]/varint.go:80 +0xa1
    github.com/multiformats/go-multistream.lpReadBuf()
        /home/runner/go/pkg/mod/github.com/multiformats/[email protected]/multistream.go:435 +0x93
    github.com/multiformats/go-multistream.ReadNextTokenBytes()
        /home/runner/go/pkg/mod/github.com/multiformats/[email protected]/multistream.go:418 +0x4f
    github.com/multiformats/go-multistream.ReadNextToken()
        /home/runner/go/pkg/mod/github.com/multiformats/[email protected]/multistream.go:407 +0x4dd
    github.com/multiformats/go-multistream.(*MultistreamMuxer).NegotiateLazy()
        /home/runner/go/pkg/mod/github.com/multiformats/[email protected]/multistream.go:267 +0x491
    github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).newStreamHandler()
        /home/runner/work/go-libp2p/go-libp2p/p2p/host/basic/basic_host.go:389 +0x115
    github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).newStreamHandler-fm()
        /home/runner/work/go-libp2p/go-libp2p/p2p/host/basic/basic_host.go:378 +0x5e
    github.com/libp2p/go-libp2p-swarm.(*Conn).start.func1.1()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/swarm_conn.go:125 +0x122
  
  Previous read at 0x00c0000f64f0 by goroutine 95:
    github.com/lucas-clemente/quic-go/internal/flowcontrol.(*streamFlowController).Abandon()
        /home/runner/go/pkg/mod/github.com/lucas-clemente/[email protected]/internal/flowcontrol/stream_flow_controller.go:100 +0x64
    github.com/lucas-clemente/quic-go.(*receiveStream).CancelRead()
        /home/runner/go/pkg/mod/github.com/lucas-clemente/[email protected]/receive_stream.go:205 +0xb7
    github.com/lucas-clemente/quic-go.(*stream).CancelRead()
        <autogenerated>:1 +0x4d
    github.com/libp2p/go-libp2p-quic-transport.(*stream).Reset()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/stream.go:36 +0x5d
    github.com/libp2p/go-libp2p-swarm.(*Stream).Reset()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/swarm_stream.go:88 +0x5b
    github.com/libp2p/go-libp2p-swarm.(*Conn).doClose()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/swarm_conn.go:75 +0x1d7
    github.com/libp2p/go-libp2p-swarm.(*Conn).doClose-fm()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/swarm_conn.go:61 +0x4a
    sync.(*Once).doSlow()
        /opt/hostedtoolcache/go/1.16.6/x64/src/sync/once.go:68 +0x109
    sync.(*Once).Do()
        /opt/hostedtoolcache/go/1.16.6/x64/src/sync/once.go:59 +0x68
    github.com/libp2p/go-libp2p-swarm.(*Conn).Close()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/swarm_conn.go:57 +0x65
    github.com/libp2p/go-libp2p-swarm.(*Swarm).ClosePeer()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/swarm.go:505 +0x485
    github.com/libp2p/go-libp2p/p2p/host/basic.TestProtoDowngrade()
        /home/runner/work/go-libp2p/go-libp2p/p2p/host/basic/basic_host_test.go:529 +0x85d
    testing.tRunner()
        /opt/hostedtoolcache/go/1.16.6/x64/src/testing/testing.go:1193 +0x202
  
  Goroutine 48 (running) created at:
    github.com/libp2p/go-libp2p-swarm.(*Conn).start.func1()
        /home/runner/go/pkg/mod/github.com/libp2p/[email protected]/swarm_conn.go:112 +0x170
  
  Goroutine 95 (running) created at:
    testing.(*T).Run()
        /opt/hostedtoolcache/go/1.16.6/x64/src/testing/testing.go:1238 +0x5d7
    testing.runTests.func1()
        /opt/hostedtoolcache/go/1.16.6/x64/src/testing/testing.go:1511 +0xa6
    testing.tRunner()
        /opt/hostedtoolcache/go/1.16.6/x64/src/testing/testing.go:1193 +0x202
    testing.runTests()
        /opt/hostedtoolcache/go/1.16.6/x64/src/testing/testing.go:1509 +0x612
    testing.(*M).Run()
        /opt/hostedtoolcache/go/1.16.6/x64/src/testing/testing.go:1417 +0x3b3
    main.main()
        _testmain.go:77 +0x236
  ==================
      testing.go:1092: race detected during execution of test
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.

1 participant