[GH-ISSUE #87] data race #66

Closed
opened 2026-03-04 01:01:36 +03:00 by kerem · 2 comments
Owner

Originally created by @stephencheng on GitHub (Mar 26, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/87

Firstly, I'd say I am amazed by this project. It's great work there.

I was using termui and now entirely stuck with lots of effort dealing with the user interaction and found it is a dead end. And I am lucky to just land here to find a rescue.

I am not sure if a data race warning should be concerned at all as I just run it for the very basic example of a box, see below

I am considering using tview to deal with a timely refresh to get data for each tab(page), would it be even possible that I can use go route to deal with the backend task(to get some server end data) for each page in the background?

Thank you

Ξ demos/box git:(master) ▶ go run -race main.go
==================
WARNING: DATA RACE
Write at 0x00c420062f18 by main goroutine:
gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell.(*tScreen).Fini()
/Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell/tscreen.go:403 +0x34b
gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview.(*Application).Stop()
/Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview/application.go:179 +0xbe
gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview.(*Application).Run()
/Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview/application.go:148 +0x51e
main.main()
/Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/examples/libs/goui/tview/demos/box/main.go:10 +0x2af
Previous read at 0x00c420062f18 by goroutine 9:
gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell.(*tScreen).mainLoop()
/Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell/tscreen.go:1253 +0xb0
Goroutine 9 (finished) created at:
gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell.(*tScreen).Init()
/Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell/tscreen.go:175 +0xab5
gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview.(*Application).Run()
/Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview/application.go:85 +0x12d
main.main()
/Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/examples/libs/goui/tview/demos/box/main.go:10 +0x2af
==================
Found 1 data race(s)
exit status 66

Originally created by @stephencheng on GitHub (Mar 26, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/87 Firstly, I'd say I am amazed by this project. It's great work there. I was using termui and now entirely stuck with lots of effort dealing with the user interaction and found it is a dead end. And I am lucky to just land here to find a rescue. I am not sure if a data race warning should be concerned at all as I just run it for the very basic example of a box, see below I am considering using tview to deal with a timely refresh to get data for each tab(page), would it be even possible that I can use go route to deal with the backend task(to get some server end data) for each page in the background? Thank you > Ξ demos/box git:(master) ▶ go run -race main.go ================== WARNING: DATA RACE Write at 0x00c420062f18 by main goroutine: gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell.(*tScreen).Fini() /Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell/tscreen.go:403 +0x34b gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview.(*Application).Stop() /Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview/application.go:179 +0xbe gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview.(*Application).Run() /Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview/application.go:148 +0x51e main.main() /Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/examples/libs/goui/tview/demos/box/main.go:10 +0x2af Previous read at 0x00c420062f18 by goroutine 9: gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell.(*tScreen).mainLoop() /Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell/tscreen.go:1253 +0xb0 Goroutine 9 (finished) created at: gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell.(*tScreen).Init() /Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/gdamore/tcell/tscreen.go:175 +0xab5 gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview.(*Application).Run() /Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/vendor/github.com/rivo/tview/application.go:85 +0x12d main.main() /Users/stephencheng/data/workspace/golangworkspace/gocmartoo/src/gitlab.com/cmartoo/goexample/examples/libs/goui/tview/demos/box/main.go:10 +0x2af ================== Found 1 data race(s) exit status 66
kerem closed this issue 2026-03-04 01:01:37 +03:00
Author
Owner

@rivo commented on GitHub (Mar 26, 2018):

It looks like this race condition is happening in tcell. You may want to open an issue there.

Generally, you should be able to use goroutines in a tview project. For example, if you write text to a TextView, you can do that asynchronously. And many of the functions in Application are thread-safe, too.

If you're setting attributes of a primitive concurrently in multiple goroutines, e.g. List.SetCurrentItem() or Table.SetCell(), you may have to synchronize those updates yourself. I guess I couldn't think of any real-life cases where you would need these functions to be thread-safe. But if you run into trouble with these in your project, let me know and I'll see if I can find a solution.

<!-- gh-comment-id:376225072 --> @rivo commented on GitHub (Mar 26, 2018): It looks like this race condition is happening in [`tcell`](https://github.com/gdamore/tcell). You may want to open an issue there. Generally, you should be able to use goroutines in a `tview` project. For example, if you write text to a `TextView`, you can do that asynchronously. And many of the functions in `Application` are thread-safe, too. If you're setting attributes of a primitive concurrently in multiple goroutines, e.g. [`List.SetCurrentItem()`](https://godoc.org/github.com/rivo/tview#List.SetCurrentItem) or [`Table.SetCell()`](https://godoc.org/github.com/rivo/tview#Table.SetCell), you may have to synchronize those updates yourself. I guess I couldn't think of any real-life cases where you would need these functions to be thread-safe. But if you run into trouble with these in your project, let me know and I'll see if I can find a solution.
Author
Owner

@stephencheng commented on GitHub (Mar 28, 2018):

Thanks for replying

<!-- gh-comment-id:376734316 --> @stephencheng commented on GitHub (Mar 28, 2018): Thanks for replying
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#66
No description provided.