hmq icon indicating copy to clipboard operation
hmq copied to clipboard

data race

Open gerdstolpmann opened this issue 4 years ago • 3 comments

We are seeing this:

WARNING: DATA RACE
Write at 0x00c0008ca0b0 by goroutine 271:
  github.com/fhmq/hmq/broker.(*client).Close()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:611 +0xb2
  github.com/fhmq/hmq/broker.ProcessMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:194 +0x411
  github.com/fhmq/hmq/broker.(*Broker).SubmitWork.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/broker.go:110 +0x44
  github.com/fhmq/hmq/pool.startWorker.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/pool/fixpool.go:55 +0x31

Previous read at 0x00c0008ca0b0 by goroutine 160:
  github.com/fhmq/hmq/broker.(*client).WriterPacket()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:662 +0x45
  github.com/fhmq/hmq/broker.publish()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/comm.go:151 +0x84
  github.com/fhmq/hmq/broker.(*client).ProcessPublishMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:326 +0x791
  github.com/fhmq/hmq/broker.(*client).processClientPublish()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:271 +0xbfd
  github.com/fhmq/hmq/broker.(*client).ProcessPublish()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:203 +0xa4
  github.com/fhmq/hmq/broker.ProcessMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:177 +0x444
  github.com/fhmq/hmq/broker.(*Broker).SubmitWork.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/broker.go:110 +0x44
  github.com/fhmq/hmq/pool.startWorker.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/pool/fixpool.go:55 +0x31

Goroutine 271 (running) created at:
  github.com/fhmq/hmq/pool.startWorker()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/pool/fixpool.go:46 +0x4c

Goroutine 160 (running) created at:
  github.com/fhmq/hmq/pool.startWorker()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/pool/fixpool.go:46 +0x4c

Data race means that some locking is missing. I briefly scanned the code, and I'm wondering whether the Client should be locked for the duration of ProcessMessage (there is a mutex mu but it seems to be unused).

gerdstolpmann avatar Sep 25 '20 12:09 gerdstolpmann

We are seeing this:

WARNING: DATA RACE
Write at 0x00c0008ca0b0 by goroutine 271:
  github.com/fhmq/hmq/broker.(*client).Close()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:611 +0xb2
  github.com/fhmq/hmq/broker.ProcessMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:194 +0x411
  github.com/fhmq/hmq/broker.(*Broker).SubmitWork.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/broker.go:110 +0x44
  github.com/fhmq/hmq/pool.startWorker.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/pool/fixpool.go:55 +0x31

Previous read at 0x00c0008ca0b0 by goroutine 160:
  github.com/fhmq/hmq/broker.(*client).WriterPacket()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:662 +0x45
  github.com/fhmq/hmq/broker.publish()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/comm.go:151 +0x84
  github.com/fhmq/hmq/broker.(*client).ProcessPublishMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:326 +0x791
  github.com/fhmq/hmq/broker.(*client).processClientPublish()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:271 +0xbfd
  github.com/fhmq/hmq/broker.(*client).ProcessPublish()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:203 +0xa4
  github.com/fhmq/hmq/broker.ProcessMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/client.go:177 +0x444
  github.com/fhmq/hmq/broker.(*Broker).SubmitWork.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/broker/broker.go:110 +0x44
  github.com/fhmq/hmq/pool.startWorker.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/pool/fixpool.go:55 +0x31

Goroutine 271 (running) created at:
  github.com/fhmq/hmq/pool.startWorker()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/pool/fixpool.go:46 +0x4c

Goroutine 160 (running) created at:
  github.com/fhmq/hmq/pool.startWorker()
      /home/circleci/project/pkg/mod/github.com/fhmq/[email protected]/pool/fixpool.go:46 +0x4c

Data race means that some locking is missing. I briefly scanned the code, and I'm wondering whether the Client should be locked for the duration of ProcessMessage (there is a mutex mu but it seems to be unused).

can you explain how to reproduce this issue?

lucasvmx avatar Feb 25 '21 20:02 lucasvmx

Reported with more details on #153

lucasvmx avatar Mar 31 '22 23:03 lucasvmx

this issue can be closed. It's fixed

lucasvmx avatar Apr 29 '22 02:04 lucasvmx