Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race in "sio" unit test #57

Open
jsccast opened this issue Jun 24, 2021 · 0 comments
Open

Race in "sio" unit test #57

jsccast opened this issue Jun 24, 2021 · 0 comments
Labels

Comments

@jsccast
Copy link
Member

jsccast commented Jun 24, 2021

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

@jsccast jsccast added the bug label Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant