muesli / termenv

Advanced ANSI style & color support for your terminal applications
MIT License
1.76k stars 73 forks source link

Data race #145

Open VladyslavLukyanenko opened 1 year ago

VladyslavLukyanenko commented 1 year ago
WARNING: DATA RACE
Write at 0x00c0001b8170 by goroutine 45:
  github.com/muesli/termenv.(*Output).BackgroundColor.func1()
      /Users/vlad/go/pkg/mod/github.com/muesli/termenv@v0.15.2/output.go:162 +0xb4
  github.com/muesli/termenv.(*Output).BackgroundColor()
      /Users/vlad/go/pkg/mod/github.com/muesli/termenv@v0.15.2/output.go:168 +0x78
  github.com/muesli/termenv.(*Output).HasDarkBackground()
      /Users/vlad/go/pkg/mod/github.com/muesli/termenv@v0.15.2/output.go:176 +0x28
  github.com/charmbracelet/lipgloss.(*Renderer).HasDarkBackground()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/lipgloss@v0.7.1/renderer.go:116 +0x90
  github.com/charmbracelet/lipgloss.AdaptiveColor.color()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/lipgloss@v0.7.1/color.go:100 +0x80
  github.com/charmbracelet/lipgloss.(*AdaptiveColor).color()
      <autogenerated>:1 +0x64
  github.com/charmbracelet/lipgloss.Style.Render()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/lipgloss@v0.7.1/style.go:257 +0x186c
  github.com/charmbracelet/bubbles/list.Model.statusView()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbles@v0.16.1/list/list.go:1108 +0x320
  github.com/charmbracelet/bubbles/list.(*Model).updatePagination()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbles@v0.16.1/list/list.go:722 +0x1dc
  github.com/charmbracelet/bubbles/list.(*Model).setSize()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbles@v0.16.1/list/list.go:641 +0x170
  github.com/charmbracelet/bubbles/list.(*Model).SetSize()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbles@v0.16.1/list/list.go:621 +0xa80
  github.com/charmbracelet/wishlist.(*ListModel).Update()
      /Users/vlad/TestArea/wishlist/wishlist.go:153 +0xa5c
  github.com/charmbracelet/bubbletea.(*Program).eventLoop()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.24.2/tea.go:373 +0x70c
  github.com/charmbracelet/bubbletea.(*Program).Run()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.24.2/tea.go:503 +0xaf0
  github.com/charmbracelet/wishlist.listingMiddleware.func1.1()
      /Users/vlad/TestArea/wishlist/middleware.go:78 +0x574
  github.com/charmbracelet/wishlist.cmdsMiddleware.func1.1()
      /Users/vlad/TestArea/wishlist/middleware.go:29 +0x188
  github.com/charmbracelet/wish/logging.MiddlewareWithLogger.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/wish@v1.1.1/logging/logging.go:46 +0x3a8
  github.com/charmbracelet/wish/activeterm.Middleware.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/wish@v1.1.1/activeterm/activeterm.go:21 +0x54
  github.com/charmbracelet/ssh.(*session).handleRequests.func1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/ssh@v0.0.0-20221117183211-483d43d97103/session.go:259 +0x4c

Previous write at 0x00c0001b8170 by goroutine 18:
  github.com/muesli/termenv.(*Output).BackgroundColor.func1()
      /Users/vlad/go/pkg/mod/github.com/muesli/termenv@v0.15.2/output.go:162 +0xb4
  github.com/muesli/termenv.(*Output).BackgroundColor()
      /Users/vlad/go/pkg/mod/github.com/muesli/termenv@v0.15.2/output.go:168 +0x78
  github.com/muesli/termenv.(*Output).HasDarkBackground()
      /Users/vlad/go/pkg/mod/github.com/muesli/termenv@v0.15.2/output.go:176 +0x28
  github.com/charmbracelet/lipgloss.(*Renderer).HasDarkBackground()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/lipgloss@v0.7.1/renderer.go:116 +0x90
  github.com/charmbracelet/lipgloss.AdaptiveColor.color()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/lipgloss@v0.7.1/color.go:100 +0x80
  github.com/charmbracelet/lipgloss.(*AdaptiveColor).color()
      <autogenerated>:1 +0x64
  github.com/charmbracelet/lipgloss.Style.Render()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/lipgloss@v0.7.1/style.go:257 +0x186c
  github.com/charmbracelet/bubbles/list.Model.statusView()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbles@v0.16.1/list/list.go:1108 +0x320
  github.com/charmbracelet/bubbles/list.(*Model).updatePagination()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbles@v0.16.1/list/list.go:722 +0x1dc
  github.com/charmbracelet/bubbles/list.(*Model).setSize()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbles@v0.16.1/list/list.go:641 +0x170
  github.com/charmbracelet/bubbles/list.(*Model).SetSize()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbles@v0.16.1/list/list.go:621 +0xa80
  github.com/charmbracelet/wishlist.(*ListModel).Update()
      /Users/vlad/TestArea/wishlist/wishlist.go:153 +0xa5c
  github.com/charmbracelet/bubbletea.(*Program).eventLoop()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.24.2/tea.go:373 +0x70c
  github.com/charmbracelet/bubbletea.(*Program).Run()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.24.2/tea.go:503 +0xaf0
  github.com/charmbracelet/wishlist.listingMiddleware.func1.1()
      /Users/vlad/TestArea/wishlist/middleware.go:78 +0x574
  github.com/charmbracelet/wishlist.cmdsMiddleware.func1.1()
      /Users/vlad/TestArea/wishlist/middleware.go:29 +0x188
  github.com/charmbracelet/wish/logging.MiddlewareWithLogger.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/wish@v1.1.1/logging/logging.go:46 +0x3a8
  github.com/charmbracelet/wish/activeterm.Middleware.func1.1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/wish@v1.1.1/activeterm/activeterm.go:21 +0x54
  github.com/charmbracelet/ssh.(*session).handleRequests.func1()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/ssh@v0.0.0-20221117183211-483d43d97103/session.go:259 +0x4c

Goroutine 45 (running) created at:
  github.com/charmbracelet/ssh.(*session).handleRequests()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/ssh@v0.0.0-20221117183211-483d43d97103/session.go:258 +0x62c
  github.com/charmbracelet/ssh.DefaultSessionHandler()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/ssh@v0.0.0-20221117183211-483d43d97103/session.go:106 +0x2d8
  github.com/charmbracelet/ssh.(*Server).HandleConn.func4()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/ssh@v0.0.0-20221117183211-483d43d97103/server.go:305 +0x84

Goroutine 18 (running) created at:
  github.com/charmbracelet/ssh.(*session).handleRequests()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/ssh@v0.0.0-20221117183211-483d43d97103/session.go:258 +0x62c
  github.com/charmbracelet/ssh.DefaultSessionHandler()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/ssh@v0.0.0-20221117183211-483d43d97103/session.go:106 +0x2d8
  github.com/charmbracelet/ssh.(*Server).HandleConn.func4()
      /Users/vlad/go/pkg/mod/github.com/charmbracelet/ssh@v0.0.0-20221117183211-483d43d97103/server.go:305 +0x84
==================

Running currently latest wishlist serve with race flag, and connecting multiple clients to the server, then as i move the terminal data race happens