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

Data race related to AutoRelay/AutoNAT #546

Closed
raulk opened this issue Mar 2, 2019 · 3 comments
Closed

Data race related to AutoRelay/AutoNAT #546

raulk opened this issue Mar 2, 2019 · 3 comments
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@raulk
Copy link
Member

raulk commented Mar 2, 2019

Running tests on CI with -race (#545) uncovered a data race:

=== RUN   TestAutoRelay
==================
WARNING: DATA RACE
Read at 0x00c0000788d8 by goroutine 49:
  github.com/libp2p/go-libp2p-autonat.(*AmbientAutoNAT).Status()
      /home/travis/gopath/pkg/mod/github.com/libp2p/[email protected]/autonat.go:88 +0x3e
  github.com/libp2p/go-libp2p/p2p/host/relay.(*AutoRelayHost).background()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/p2p/host/relay/autorelay.go:98 +0x1ff
Previous write at 0x00c0000788d8 by goroutine 48:
  github.com/libp2p/go-libp2p-autonat.(*AmbientAutoNAT).autodetect()
      /home/travis/gopath/pkg/mod/github.com/libp2p/[email protected]/autonat.go:173 +0x663
  github.com/libp2p/go-libp2p-autonat.(*AmbientAutoNAT).background()
      /home/travis/gopath/pkg/mod/github.com/libp2p/[email protected]/autonat.go:112 +0x148
Goroutine 49 (running) created at:
  github.com/libp2p/go-libp2p/p2p/host/relay.NewAutoRelayHost()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/p2p/host/relay/autorelay.go:71 +0x431
  github.com/libp2p/go-libp2p/config.(*Config).NewNode()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/config/config.go:211 +0xc51
  github.com/libp2p/go-libp2p.NewWithoutDefaults()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/libp2p.go:68 +0x132
  github.com/libp2p/go-libp2p.New()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/libp2p.go:54 +0x12f
  github.com/libp2p/go-libp2p/p2p/host/relay_test.TestAutoRelay()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/p2p/host/relay/autorelay_test.go:150 +0x445
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
Goroutine 48 (running) created at:
  github.com/libp2p/go-libp2p-autonat.NewAutoNAT()
      /home/travis/gopath/pkg/mod/github.com/libp2p/[email protected]/autonat.go:82 +0x1e3
  github.com/libp2p/go-libp2p/p2p/host/relay.NewAutoRelayHost()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/p2p/host/relay/autorelay.go:68 +0x2e5
  github.com/libp2p/go-libp2p/config.(*Config).NewNode()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/config/config.go:211 +0xc51
  github.com/libp2p/go-libp2p.NewWithoutDefaults()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/libp2p.go:68 +0x132
  github.com/libp2p/go-libp2p.New()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/libp2p.go:54 +0x12f
  github.com/libp2p/go-libp2p/p2p/host/relay_test.TestAutoRelay()
      /home/travis/gopath/src/github.com/libp2p/go-libp2p/p2p/host/relay/autorelay_test.go:150 +0x445
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
==================
--- FAIL: TestAutoRelay (5.98s)
    testing.go:771: race detected during execution of test
FAIL

Possibly related to libp2p/go-libp2p-autonat#16.

@raulk raulk added kind/bug A bug in existing code (including security flaws) P0 Critical: Tackled by core team ASAP labels Mar 2, 2019
@vyzo
Copy link
Contributor

vyzo commented Mar 2, 2019

What's the race here? It seems that it is on the Status(), which is totally benign.

@vyzo vyzo removed the P0 Critical: Tackled by core team ASAP label Mar 2, 2019
@vyzo
Copy link
Contributor

vyzo commented Mar 2, 2019

This is not a critical bug, a rather benign race that is easily fixed by mutex protecting the boolean access.

@vyzo
Copy link
Contributor

vyzo commented Mar 2, 2019

Fixed in libp2p/go-libp2p-autonat#17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

No branches or pull requests

3 participants