zserge / lorca

Build cross-platform modern desktop apps in Go + HTML5
MIT License
8.04k stars 535 forks source link

lorca race detect #82

Open prospero78 opened 4 years ago

prospero78 commented 4 years ago

when im starting my app -- race detector detect race in two gorutines (in create object of UI, and in parallel task this object in update DIV-element ).

zserge commented 4 years ago

@prospero78 Could you please share the output of the race condition dump (it should normally print a stack trace of the error)?

prospero78 commented 4 years ago

Unfortunately, but the dump was not preserved. I just launched a data exchange cycle with a web browser in a separate thread. And then the show began.

mylxsw commented 4 years ago
==================
WARNING: DATA RACE
Write at 0x00c0001e0ba8 by goroutine 9:
  os/exec.(*Cmd).Wait()
      /usr/local/Cellar/go/1.14.1/libexec/src/os/exec/exec.go:506 +0x168
  github.com/zserge/lorca.New.func1()
      /Users/mylxsw/codes/golang/pkg/mod/github.com/zserge/lorca@v0.1.9/ui.go:86 +0x50

Previous read at 0x00c0001e0ba8 by goroutine 8:
  github.com/zserge/lorca.(*chrome).kill()
      /Users/mylxsw/codes/golang/pkg/mod/github.com/zserge/lorca@v0.1.9/chrome.go:513 +0x92
  github.com/zserge/lorca.(*chrome).readLoop()
      /Users/mylxsw/codes/golang/pkg/mod/github.com/zserge/lorca@v0.1.9/chrome.go:339 +0x13a8

Goroutine 9 (running) created at:
  github.com/zserge/lorca.New()
      /Users/mylxsw/codes/golang/pkg/mod/github.com/zserge/lorca@v0.1.9/ui.go:85 +0x631
  main.main()
      /Users/mylxsw/codes/github/wizard-personal/cmd/wizard/main.go:37 +0xc6

Goroutine 8 (finished) created at:
  github.com/zserge/lorca.newChromeWithArgs()
      /Users/mylxsw/codes/golang/pkg/mod/github.c  github.com/zserge/lorca.New()
      /Users/mylxsw/codes/golang/pkg/mod/github.com/zserge/lorca@v0.1.9/ui.go:79 +0x5af
  main.main()
      /Users/mylxsw/codes/github/wizard-personal/cmd/wizard/main.go:37 +0xc6
==================
prospero78 commented 4 years ago

I solved this problem by allocating the main thread of execution in a separate thread. And all the signals arrive on different channels in a separate stream. Although it is worth recognizing: the situation is sad, and the author abandoned his project a bit.