Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Data race between StandardMeter Stop and Mark #245

@sykesm

Description

@sykesm

The implementation of Stop is using a lock instead of atomic.CompareAndSwapUint32 to serialize the stopped flag. This races with the implementation of Mark that uses atomic.LoadUint32 as there is no serialization guarantee between the two.

WARNING: DATA RACE
Write at 0x00c420312478 by goroutine 126:
  github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics.(*StandardMeter).Stop()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics/meter.go:151 +0x6f
  github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics.(*StandardRegistry).stop()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics/registry.go:227 +0xe4
  github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics.(*StandardRegistry).Unregister()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics/registry.go:189 +0x8f
  github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).Close()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:186 +0x6cc
  github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.safeAsyncClose.func1()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/utils.go:52 +0x70
  github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.withRecover()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/utils.go:45 +0x50

Previous read at 0x00c420312478 by goroutine 111:
  sync/atomic.LoadInt32()
      /opt/go/src/runtime/race_amd64.s:206 +0xb
  github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics.(*StandardMeter).Mark()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics/meter.go:167 +0x42
  github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).updateOutgoingCommunicationMetrics()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:878 +0x1db
  github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).send()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:582 +0x50c
  github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).sendAndReceive()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:601 +0x80
  github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).Produce()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:267 +0x138
  github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*asyncProducer).newBrokerProducer.func1()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/async_producer.go:572 +0xe1
  github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.withRecover()
      /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/utils.go:45 +0x50

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions