Skip to content

Race in "sio" unit test #57

Open
Open
@jsccast

Description

The problem is a logging line that JSON-serializes state that includes the Timers map (itself and not the Timers instance, which does have an available sync.Mutex).

WARNING: DATA RACE
Read at 0x00c0001b1170 by goroutine 9:
  reflect.maplen()
      /home/somebody/go/src/runtime/map.go:1360 +0x0
  reflect.Value.MapKeys()
      /home/somebody/go/src/reflect/value.go:1213 +0x3a4
  encoding/json.mapEncoder.encode()
      /home/somebody/go/src/encoding/json/encode.go:797 +0x189
  encoding/json.mapEncoder.encode-fm()
      /home/somebody/go/src/encoding/json/encode.go:779 +0x88
  encoding/json.(*encodeState).reflectValue()
      /home/somebody/go/src/encoding/json/encode.go:360 +0x93
  encoding/json.interfaceEncoder()
      /home/somebody/go/src/encoding/json/encode.go:716 +0xfb
  encoding/json.mapEncoder.encode()
      /home/somebody/go/src/encoding/json/encode.go:813 +0x3cc
  encoding/json.mapEncoder.encode-fm()
      /home/somebody/go/src/encoding/json/encode.go:779 +0x88
  encoding/json.structEncoder.encode()
      /home/somebody/go/src/encoding/json/encode.go:761 +0x3c6
  encoding/json.structEncoder.encode-fm()
      /home/somebody/go/src/encoding/json/encode.go:732 +0xb1
  encoding/json.ptrEncoder.encode()
      /home/somebody/go/src/encoding/json/encode.go:944 +0x1c4
  encoding/json.ptrEncoder.encode-fm()
      /home/somebody/go/src/encoding/json/encode.go:929 +0x88
  encoding/json.structEncoder.encode()
      /home/somebody/go/src/encoding/json/encode.go:761 +0x3c6
  encoding/json.structEncoder.encode-fm()
      /home/somebody/go/src/encoding/json/encode.go:732 +0xb1
  encoding/json.ptrEncoder.encode()
      /home/somebody/go/src/encoding/json/encode.go:944 +0x1c4
  encoding/json.ptrEncoder.encode-fm()
      /home/somebody/go/src/encoding/json/encode.go:929 +0x88
  encoding/json.(*encodeState).reflectValue()
      /home/somebody/go/src/encoding/json/encode.go:360 +0x93
  encoding/json.interfaceEncoder()
      /home/somebody/go/src/encoding/json/encode.go:716 +0xfb
  encoding/json.ptrEncoder.encode()
      /home/somebody/go/src/encoding/json/encode.go:944 +0x1c4
  encoding/json.ptrEncoder.encode-fm()
      /home/somebody/go/src/encoding/json/encode.go:929 +0x88
  encoding/json.(*encodeState).reflectValue()
      /home/somebody/go/src/encoding/json/encode.go:360 +0x93
  encoding/json.(*encodeState).marshal()
      /home/somebody/go/src/encoding/json/encode.go:332 +0xd2
  encoding/json.Marshal()
      /home/somebody/go/src/encoding/json/encode.go:161 +0x78
  github.com/Comcast/sheens/sio.JS()
      /home/somebody/src/sheens/sio/util.go:30 +0x104
  github.com/Comcast/sheens/sio.JShort()
      /home/somebody/src/sheens/sio/util.go:51 +0x64
  github.com/Comcast/sheens/sio.(*Stdio).IO.func3()
      /home/somebody/src/sheens/sio/stdio.go:199 +0x23a

Previous write at 0x00c0001b1170 by goroutine 7:
  runtime.mapassign_faststr()
      /home/somebody/go/src/runtime/map_faststr.go:202 +0x0
  github.com/Comcast/sheens/sio.(*Timers).add()
      /home/somebody/src/sheens/sio/timers.go:110 +0x129
  github.com/Comcast/sheens/sio.(*Timers).Add()
      /home/somebody/src/sheens/sio/timers.go:134 +0x335
  github.com/Comcast/sheens/sio.(*Crew).NewTimersSpec.func2()
      /home/somebody/src/sheens/sio/timersspec.go:104 +0x7bd
  github.com/Comcast/sheens/core.(*FuncAction).Exec()
      /home/somebody/src/sheens/core/actions.go:167 +0x32d
  github.com/Comcast/sheens/core.(*Spec).Step()
      /home/somebody/src/sheens/core/step.go:273 +0x1005
  github.com/Comcast/sheens/core.(*Spec).Walk()
      /home/somebody/src/sheens/core/step.go:640 +0x3b5
  github.com/Comcast/sheens/sio.(*Crew).RunMachine()
      /home/somebody/src/sheens/sio/crew.go:496 +0x37c
  github.com/Comcast/sheens/sio.(*Crew).RunMachines()
      /home/somebody/src/sheens/sio/crew.go:455 +0x2c4
  github.com/Comcast/sheens/sio.(*Crew).ProcessMsg()
      /home/somebody/src/sheens/sio/crew.go:271 +0x738
  github.com/Comcast/sheens/sio.(*Crew).Loop()
      /home/somebody/src/sheens/sio/crew.go:374 +0x1da
  github.com/Comcast/sheens/sio.TestCrew()
      /home/somebody/src/sheens/sio/crew_test.go:104 +0xc64
  testing.tRunner()
      /home/somebody/go/src/testing/testing.go:1194 +0x202

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions