containers / virtcontainers

A Go package for building hardware virtualized container runtimes
Apache License 2.0
139 stars 43 forks source link

Virtcontainer race conditions #582

Closed sameo closed 6 years ago

sameo commented 6 years ago

When running the vc unit tests with -race, we get the following errors:

==================
WARNING: DATA RACE
Write at 0x00c4200b3ab0 by goroutine 45:
  github.com/containers/virtcontainers.(*Container).setContainerState()
      github.com/containers/virtcontainers/_test/_obj_test/container.go:335 +0xa0
  github.com/containers/virtcontainers.(*Container).stop()
      github.com/containers/virtcontainers/_test/_obj_test/container.go:720 +0x82e
  github.com/containers/virtcontainers.statusContainer.func1()
      github.com/containers/virtcontainers/_test/_obj_test/api.go:690 +0x12f

Previous read at 0x00c4200b3ab0 by goroutine 44:
  github.com/containers/virtcontainers.statusContainer()
      github.com/containers/virtcontainers/_test/_obj_test/api.go:701 +0x2ff
  github.com/containers/virtcontainers.StatusPod()
      github.com/containers/virtcontainers/_test/_obj_test/api.go:348 +0x341
  github.com/containers/virtcontainers.TestStatusPodSuccessfulStateRunning()
      /home/samuel/devlp/gopath/src/github.com/containers/virtcontainers/api_test.go:694 +0x819
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:746 +0x16c

Goroutine 45 (running) created at:
  github.com/containers/virtcontainers.statusContainer()
      github.com/containers/virtcontainers/_test/_obj_test/api.go:679 +0x777
  github.com/containers/virtcontainers.StatusPod()
      github.com/containers/virtcontainers/_test/_obj_test/api.go:348 +0x341
  github.com/containers/virtcontainers.TestStatusPodSuccessfulStateRunning()
      /home/samuel/devlp/gopath/src/github.com/containers/virtcontainers/api_test.go:694 +0x819
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:746 +0x16c

Goroutine 44 (running) created at:
  testing.(*T).Run()
      /usr/lib/golang/src/testing/testing.go:789 +0x568
  testing.runTests.func1()
      /usr/lib/golang/src/testing/testing.go:1004 +0xa7
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:746 +0x16c
  testing.runTests()
      /usr/lib/golang/src/testing/testing.go:1002 +0x521
  testing.(*M).Run()
      /usr/lib/golang/src/testing/testing.go:921 +0x206
  github.com/containers/virtcontainers.TestMain()
      /home/samuel/devlp/gopath/src/github.com/containers/virtcontainers/virtcontainers_test.go:143 +0x188b
  main.main()
      github.com/containers/virtcontainers/_test/_testmain.go:962 +0x2f0
==================
--- FAIL: TestStatusPodSuccessfulStateRunning (0.01s)
    testing.go:699: race detected during execution of test
==================
WARNING: DATA RACE
Write at 0x00c4200b3330 by goroutine 18:
  github.com/containers/virtcontainers.(*Container).setContainerState()
      github.com/containers/virtcontainers/_test/_obj_test/container.go:335 +0xa0
  github.com/containers/virtcontainers.(*Container).stop()
      github.com/containers/virtcontainers/_test/_obj_test/container.go:720 +0x82e
  github.com/containers/virtcontainers.statusContainer.func1()
      github.com/containers/virtcontainers/_test/_obj_test/api.go:690 +0x12f

Previous read at 0x00c4200b3330 by goroutine 17:
  github.com/containers/virtcontainers.statusContainer()
      github.com/containers/virtcontainers/_test/_obj_test/api.go:701 +0x2ff
  github.com/containers/virtcontainers.TestStatusContainerStateRunning()
      /home/samuel/devlp/gopath/src/github.com/containers/virtcontainers/api_test.go:1548 +0xb2a
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:746 +0x16c

Goroutine 18 (running) created at:
  github.com/containers/virtcontainers.statusContainer()
      github.com/containers/virtcontainers/_test/_obj_test/api.go:679 +0x777
  github.com/containers/virtcontainers.TestStatusContainerStateRunning()
      /home/samuel/devlp/gopath/src/github.com/containers/virtcontainers/api_test.go:1548 +0xb2a
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:746 +0x16c

Goroutine 17 (running) created at:
  testing.(*T).Run()
      /usr/lib/golang/src/testing/testing.go:789 +0x568
  testing.runTests.func1()
      /usr/lib/golang/src/testing/testing.go:1004 +0xa7
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:746 +0x16c
  testing.runTests()
      /usr/lib/golang/src/testing/testing.go:1002 +0x521
  testing.(*M).Run()
      /usr/lib/golang/src/testing/testing.go:921 +0x206
  github.com/containers/virtcontainers.TestMain()
      /home/samuel/devlp/gopath/src/github.com/containers/virtcontainers/virtcontainers_test.go:143 +0x188b
  main.main()
      github.com/containers/virtcontainers/_test/_testmain.go:962 +0x2f0
==================
--- FAIL: TestStatusContainerStateRunning (0.01s)
    testing.go:699: race detected during execution of test
Some output on stderrtime="2018-01-24T15:39:10+01:00" level=error msg="hook error" error="exit status 1: stdout: , stderr: " hook-type=pre-start source=virtcontainers subsystem=hooks
Some output on stderrFAIL
coverage: 61.7% of statements
FAIL    github.com/containers/virtcontainers    4.566s
make: *** [Makefile:55: check-go-test] Error 1
egernst commented 6 years ago

This issue was moved to kata-containers/runtime#153