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

x/exp/shiny: gldriver(x11) race condition showWindow/onConfigure #18549

Closed
barnex opened this issue Jan 6, 2017 · 1 comment
Closed

x/exp/shiny: gldriver(x11) race condition showWindow/onConfigure #18549

barnex opened this issue Jan 6, 2017 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@barnex
Copy link

barnex commented Jan 6, 2017

What did you do?

$ cd $GOPATH/src/golang.org/x/exp/shiny/example/basicgl
$ go build -race main.go
$ ./main

What did you see?

==================
WARNING: DATA RACE
Write at 0x00c4200fa0c8 by goroutine 6:
  golang.org/x/exp/shiny/driver/gldriver.showWindow()
      /home/arne/src/golang.org/x/exp/shiny/driver/gldriver/x11.go:73 +0x1f3
  golang.org/x/exp/shiny/driver/gldriver.(*screenImpl).NewWindow()
      /home/arne/src/golang.org/x/exp/shiny/driver/gldriver/screen.go:145 +0x33d
  golang.org/x/exp/shiny/widget.RunWindow()
      /home/arne/src/golang.org/x/exp/shiny/widget/widget.go:77 +0xb1
  main.main.func1()
      /home/arne/src/golang.org/x/exp/shiny/example/basicgl/main.go:51 +0x4cd
  golang.org/x/exp/shiny/driver/gldriver.main.func1()
      /home/arne/src/golang.org/x/exp/shiny/driver/gldriver/x11.go:127 +0x5b

Previous read at 0x00c4200fa0c8 by main goroutine:
  golang.org/x/exp/shiny/driver/gldriver.onConfigure()
      /home/arne/src/golang.org/x/exp/shiny/driver/gldriver/x11.go:279 +0x1ac
  golang.org/x/exp/shiny/driver/gldriver._cgoexpwrap_0cf67038b08c_onConfigure()
      golang.org/x/exp/shiny/driver/gldriver/_obj/_cgo_gotypes.go:221 +0x68
  runtime.call32()
      /home/arne/bin/go/src/runtime/asm_amd64.s:479 +0x4b
  golang.org/x/exp/shiny/driver/gldriver.main()
      /home/arne/src/golang.org/x/exp/shiny/driver/gldriver/x11.go:162 +0x5d6
  golang.org/x/exp/shiny/driver/gldriver.Main()
      /home/arne/src/golang.org/x/exp/shiny/driver/gldriver/gldriver.go:26 +0x3c
  main.main()
      /home/arne/src/golang.org/x/exp/shiny/example/basicgl/main.go:54 +0x3a

Goroutine 6 (running) created at:
  golang.org/x/exp/shiny/driver/gldriver.main()
      /home/arne/src/golang.org/x/exp/shiny/driver/gldriver/x11.go:129 +0x2ae
  golang.org/x/exp/shiny/driver/gldriver.Main()
      /home/arne/src/golang.org/x/exp/shiny/driver/gldriver/gldriver.go:26 +0x3c
  main.main()
      /home/arne/src/golang.org/x/exp/shiny/example/basicgl/main.go:54 +0x3a
==================

Sometimes onConfigure even segfaults:

$ ./main
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x498 pc=0x49799c]

goroutine 21 [running]:
panic(0x56e6c0, 0xc42000c140)
	/home/arne/bin/go/src/runtime/panic.go:500 +0x1ae
golang.org/x/exp/shiny/driver/gldriver.onConfigure.func1(0xc420110000, 0x58900000358)
	/home/arne/src/golang.org/x/exp/shiny/driver/gldriver/x11.go:274 +0x6c
created by golang.org/x/exp/shiny/driver/gldriver.onConfigure
	/home/arne/src/golang.org/x/exp/shiny/driver/gldriver/x11.go:276 +0x14d

This behaviour is flaky and hard to reproduce. I use the i3 window manager, which re-sizes windows as soon as they are created. This may tickle the race.

Playing with w.glctxMu guarding w.glctx I could avoid the race, but I introduced deadlocks later on instead.

What version of Go are you using (go version)?

go version go1.7.1 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/arne"
GORACE=""
GOROOT="/home/arne/bin/go"
GOTOOLDIR="/home/arne/bin/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build838115997=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
@titanous titanous added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 7, 2017
@titanous titanous added this to the Unreleased milestone Jan 7, 2017
@barnex
Copy link
Author

barnex commented Jan 7, 2017

Thanks @nigeltao for the prompt fix: https://go-review.googlesource.com/#/c/34873/

@titanous titanous changed the title exp/shiny: gldriver(x11) race condition showWindow/onConfigure x/exp/shiny: gldriver(x11) race condition showWindow/onConfigure Jan 7, 2017
@golang golang locked and limited conversation to collaborators Feb 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants