Git Product home page Git Product logo

clock's People

Contributors

bboreham avatar benbjohnson avatar nomis52 avatar samihiltunen avatar

Watchers

 avatar  avatar

clock's Issues

Ticker test is racey

Another test race found by running go test -race -count=10000

Output:

==================
WARNING: DATA RACE
Write at 0x00c4200fc220 by goroutine 60:
  sync/atomic.StoreInt32()
      /usr/local/Cellar/go/1.8.3/libexec/src/runtime/race_amd64.s:229 +0xb
  clock.TestClock_Ticker.func1()
      /Users/zkipp/go/src/clock/clock_test.go:113 +0x4d

Previous write at 0x00c4200fc220 by goroutine 59:
  clock.TestClock_Ticker()
      /Users/zkipp/go/src/clock/clock_test.go:126 +0x1d6
  testing.tRunner()
      /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107

Goroutine 60 (running) created at:
  clock.TestClock_Ticker()
      /Users/zkipp/go/src/clock/clock_test.go:114 +0xb3
  testing.tRunner()
      /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107

Goroutine 59 (running) created at:
  testing.(*T).Run()
      /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:697 +0x543
  testing.runTests.func1()
      /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:882 +0xaa
  testing.tRunner()
      /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107
  testing.runTests()
      /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:888 +0x4e0
  testing.(*M).Run()
      /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:822 +0x1c3
  main.main()
      clock/_test/_testmain.go:90 +0x20f
==================
--- FAIL: TestClock_Ticker (0.10s)
	clock_test.go:127: too early
	testing.go:610: race detected during execution of test

Timer.Stop() is racey

If Timer.Stop() is called when an internal Tick() occurs which marks the underlying Timer as stopped, a race occurs for writes to the variable stopped. See the following race detector output (some verbose output removed):

==================
WARNING: DATA RACE
Read at 0x00c4201d1800 by goroutine 126:
  github.com/Zacho2/clock.(*Timer).Stop()
      /Users/zkipp/go/src/github.com/Zacho2/clock/clock.go:255 +0xac

Previous write at 0x00c4201d1800 by goroutine 124:
  github.com/Zacho2/clock.(*internalTimer).Tick()
      /Users/zkipp/go/src/github.com/Zacho2/clock/clock.go:288 +0xbd
  github.com/Zacho2/clock.(*Mock).runNextTimer()
      /Users/zkipp/go/src/github.com/Zacho2/clock/clock.go:136 +0x1f1
  github.com/Zacho2/clock.(*Mock).Add()
      /Users/zkipp/go/src/github.com/Zacho2/clock/clock.go:76 +0xd7
==================

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.