Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Data races in PSS - TestProtocol #1157

Closed
frncmx opened this issue Jan 23, 2019 · 1 comment · Fixed by ethereum/go-ethereum#18523
Closed

Data races in PSS - TestProtocol #1157

frncmx opened this issue Jan 23, 2019 · 1 comment · Fixed by ethereum/go-ethereum#18523
Assignees

Comments

@frncmx
Copy link
Contributor

frncmx commented Jan 23, 2019

Similar to #1116 but a different test is failing.

How to reproduce?

go test -race -count 1 -run TestProtocol github.com/ethereum/go-ethereum/swarm/pss

Acceptance criteria

All PSS tests pass without data race.
go test -race -count 1 github.com/ethereum/go-ethereum/swarm/pss...

Stack trace

==================
WARNING: DATA RACE
Write at 0x00c000259ec0 by goroutine 105:
  runtime.mapassign_fast32()
      /usr/lib/go/src/runtime/map_fast32.go:92 +0x0
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).deregister()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:360 +0x3c5
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).Register.func1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:341 +0x53
  github.com/ethereum/go-ethereum/swarm/pss.(*API).Receive.func2()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/api.go:89 +0x1bf

Previous read at 0x00c000259ec0 by goroutine 124:
  runtime.mapaccess1_fast32()
      /usr/lib/go/src/runtime/map_fast32.go:12 +0x0
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).send()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:889 +0xc6f
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).SendAsym()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:824 +0x29b
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).SendAsym-fm()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/protocol.go:239 +0x93
  github.com/ethereum/go-ethereum/swarm/pss.(*PssReadWriter).WriteMsg()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/protocol.go:108 +0x3ae
  github.com/ethereum/go-ethereum/p2p.Send()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/p2p/message.go:97 +0xed
  github.com/ethereum/go-ethereum/p2p/protocols.(*Peer).Send()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/p2p/protocols/protocol.go:303 +0x685
  github.com/ethereum/go-ethereum/swarm/pss.NewPingProtocol.func1.1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/ping.go:84 +0x203

Goroutine 105 (running) created at:
  github.com/ethereum/go-ethereum/swarm/pss.(*API).Receive()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/api.go:81 +0x2a9
  runtime.call64()
      /usr/lib/go/src/runtime/asm_amd64.s:523 +0x3a
  reflect.Value.Call()
      /usr/lib/go/src/reflect/value.go:308 +0xc0
  github.com/ethereum/go-ethereum/rpc.(*Server).createSubscription()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:245 +0x276
  github.com/ethereum/go-ethereum/rpc.(*Server).handle()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:278 +0x6ea
  github.com/ethereum/go-ethereum/rpc.(*Server).exec()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:330 +0x23d
  github.com/ethereum/go-ethereum/rpc.(*Server).serveRequest.func2()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:204 +0x178

Goroutine 124 (running) created at:
  github.com/ethereum/go-ethereum/swarm/pss.NewPingProtocol.func1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/ping.go:80 +0x245
  github.com/ethereum/go-ethereum/swarm/pss.(*Protocol).AddPeer.func1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/protocol.go:263 +0xa9
==================


==================
WARNING: DATA RACE
Write at 0x00c00024ad48 by goroutine 105:
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).deregister()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:360 +0x3da
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).Register.func1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:341 +0x53
  github.com/ethereum/go-ethereum/swarm/pss.(*API).Receive.func2()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/api.go:89 +0x1bf

Previous read at 0x00c00024ad48 by goroutine 124:
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).send()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:889 +0xc85
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).SendAsym()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:824 +0x29b
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).SendAsym-fm()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/protocol.go:239 +0x93
  github.com/ethereum/go-ethereum/swarm/pss.(*PssReadWriter).WriteMsg()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/protocol.go:108 +0x3ae
  github.com/ethereum/go-ethereum/p2p.Send()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/p2p/message.go:97 +0xed
  github.com/ethereum/go-ethereum/p2p/protocols.(*Peer).Send()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/p2p/protocols/protocol.go:303 +0x685
  github.com/ethereum/go-ethereum/swarm/pss.NewPingProtocol.func1.1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/ping.go:84 +0x203

Goroutine 105 (running) created at:
  github.com/ethereum/go-ethereum/swarm/pss.(*API).Receive()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/api.go:81 +0x2a9
  runtime.call64()
      /usr/lib/go/src/runtime/asm_amd64.s:523 +0x3a
  reflect.Value.Call()
      /usr/lib/go/src/reflect/value.go:308 +0xc0
  github.com/ethereum/go-ethereum/rpc.(*Server).createSubscription()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:245 +0x276
  github.com/ethereum/go-ethereum/rpc.(*Server).handle()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:278 +0x6ea
  github.com/ethereum/go-ethereum/rpc.(*Server).exec()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:330 +0x23d
  github.com/ethereum/go-ethereum/rpc.(*Server).serveRequest.func2()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:204 +0x178

Goroutine 124 (running) created at:
  github.com/ethereum/go-ethereum/swarm/pss.NewPingProtocol.func1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/ping.go:80 +0x245
  github.com/ethereum/go-ethereum/swarm/pss.(*Protocol).AddPeer.func1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/protocol.go:263 +0xa9
==================

==================
WARNING: DATA RACE
Write at 0x00c0015d91a0 by goroutine 264:
  runtime.mapassign_fast32()
      /usr/lib/go/src/runtime/map_fast32.go:92 +0x0
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).deregister()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:360 +0x3c5
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).Register.func1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:341 +0x53
  github.com/ethereum/go-ethereum/swarm/pss.(*API).Receive.func2()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/api.go:89 +0x1bf

Previous read at 0x00c0015d91a0 by goroutine 187:
  runtime.mapaccess2_fast32()
      /usr/lib/go/src/runtime/map_fast32.go:52 +0x0
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).send()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:888 +0xbd0
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).SendAsym()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/pss.go:824 +0x29b
  github.com/ethereum/go-ethereum/swarm/pss.(*Pss).SendAsym-fm()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/protocol.go:239 +0x93
  github.com/ethereum/go-ethereum/swarm/pss.(*PssReadWriter).WriteMsg()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/protocol.go:108 +0x3ae
  github.com/ethereum/go-ethereum/p2p.Send()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/p2p/message.go:97 +0xed
  github.com/ethereum/go-ethereum/p2p/protocols.(*Peer).Send()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/p2p/protocols/protocol.go:303 +0x685
  github.com/ethereum/go-ethereum/swarm/pss.NewPingProtocol.func1.1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/ping.go:84 +0x203

Goroutine 264 (running) created at:
  github.com/ethereum/go-ethereum/swarm/pss.(*API).Receive()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/api.go:81 +0x2a9
  runtime.call64()
      /usr/lib/go/src/runtime/asm_amd64.s:523 +0x3a
  reflect.Value.Call()
      /usr/lib/go/src/reflect/value.go:308 +0xc0
  github.com/ethereum/go-ethereum/rpc.(*Server).createSubscription()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:245 +0x276
  github.com/ethereum/go-ethereum/rpc.(*Server).handle()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:278 +0x6ea
  github.com/ethereum/go-ethereum/rpc.(*Server).exec()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:330 +0x23d
  github.com/ethereum/go-ethereum/rpc.(*Server).serveRequest.func2()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/rpc/server.go:204 +0x178

Goroutine 187 (running) created at:
  github.com/ethereum/go-ethereum/swarm/pss.NewPingProtocol.func1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/ping.go:80 +0x245
  github.com/ethereum/go-ethereum/swarm/pss.(*Protocol).AddPeer.func1()
      /home/frncmx/code/src/github.com/ethereum/go-ethereum/swarm/pss/protocol.go:263 +0xa9
==================
--- FAIL: TestProtocol (3.35s)
    --- FAIL: TestProtocol/32 (1.09s)
        testing.go:771: race detected during execution of test
    --- FAIL: TestProtocol/0 (1.15s)
        testing.go:771: race detected during execution of test
    testing.go:771: race detected during execution of test
FAIL
FAIL	github.com/ethereum/go-ethereum/swarm/pss	3.424s
@frncmx
Copy link
Contributor Author

frncmx commented Jan 23, 2019

@gluk256 similar to #1116 ; I just did not want to reopen the ticket.

@frncmx frncmx self-assigned this Jan 24, 2019
frncmx pushed a commit that referenced this issue Jan 25, 2019
topicHandlerCaps had concurrent read and write access without any
synchronisation primitive.

Failing test was:
go test -race -count 1 -run TestProtocol ./swarm/pss

fixes #1157
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
1 participant