Skip to content

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

@barnex

Description

@barnex

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions