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

Data race on cursor.(*Model).BlinkCmd.func1 #909

Open
3v1n0 opened this issue Jan 22, 2024 · 0 comments
Open

Data race on cursor.(*Model).BlinkCmd.func1 #909

3v1n0 opened this issue Jan 22, 2024 · 0 comments

Comments

@3v1n0
Copy link

3v1n0 commented Jan 22, 2024

Describe the bug
A clear and concise description of what the bug is.

Setup
Please complete the following information along with version numbers, if applicable.

  • OS: Ubuntu
  • Shell zsh
  • Terminal Emulator tilix

To Reproduce
In a test case where I'm sending events, I'm getting data races on blink commands

Source Code
Please include source code if needed to reproduce the behavior.

The previous write happened in the func (m *UIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) implementation of the main model where we have

m.userSelectionModel, cmd = m.userSelectionModel.Update(msg)

// where userSelectionModel is defined as `userSelectionMode{}`
type userSelectionModel struct {
	textinput.Model

	// ...
}

So basically writing to m.userSelectionModel.

Trace

Read at 0x00c0006d86d8 by goroutine 385:
  github.com/charmbracelet/bubbles/cursor.(*Model).BlinkCmd.func1()
      /tmp/go-path/pkg/mod/github.com/charmbracelet/bubbles@v0.17.1/cursor/cursor.go:168 +0x164
  github.com/charmbracelet/bubbletea.(*Program).eventLoop.func1()
      /tmp/go-path/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:381 +0x8c

Previous write at 0x00c0006d86d8 by goroutine 372:
  github.com/ubuntu/authd/pam/internal/adapter.(*UIModel).Update()
      /home/marco/Dev/authd/pam/internal/adapter/model.go:274 +0x2566
  github.com/ubuntu/authd/pam/internal/adapter.(*mockUIModel).Update()
      /home/marco/Dev/authd/pam/internal/adapter/gdmmodel_test.go:420 +0x65
  github.com/charmbracelet/bubbletea.(*Program).eventLoop()
      /tmp/go-path/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:411 +0xa3b
  github.com/charmbracelet/bubbletea.(*Program).Run()
      /tmp/go-path/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:543 +0xff6
  github.com/ubuntu/authd/pam/internal/adapter.TestGdmModel.func5()
      /home/marco/Dev/authd/pam/internal/adapter/gdmmodel_test.go:734 +0xc31
  testing.tRunner()
      /snap/go/10489/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      /snap/go/10489/src/testing/testing.go:1648 +0x44

Goroutine 385 (running) created at:
  github.com/charmbracelet/bubbletea.(*Program).eventLoop()
      /tmp/go-path/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:374 +0x4cb
  github.com/charmbracelet/bubbletea.(*Program).Run()
      /tmp/go-path/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:543 +0xff6
  github.com/ubuntu/authd/pam/internal/adapter.TestGdmModel.func5()
      /home/marco/Dev/authd/pam/internal/adapter/gdmmodel_test.go:734 +0xc31
  testing.tRunner()
      /snap/go/10489/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      /snap/go/10489/src/testing/testing.go:1648 +0x44

Goroutine 372 (finished) created at:
  testing.(*T).Run()
      /snap/go/10489/src/testing/testing.go:1648 +0x845
  github.com/ubuntu/authd/pam/internal/adapter.TestGdmModel()
      /home/marco/Dev/authd/pam/internal/adapter/gdmmodel_test.go:644 +0x13ef
  testing.tRunner()
      /snap/go/10489/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      /snap/go/10489/src/testing/testing.go:1648 +0x44

Workaround is to avoid blinking... So using textinput.Model.Cursor.SetMode(cursor.CursorHide).

3v1n0 added a commit to 3v1n0/authd that referenced this issue Jan 29, 2024
… mode

It's causing events to happen that we don't really need in this case
and also it's causing races.

See: charmbracelet/bubbletea#909
3v1n0 added a commit to 3v1n0/authd that referenced this issue Jan 29, 2024
… mode

It's causing events to happen that we don't really need in this case
and also it's causing races.

See: charmbracelet/bubbletea#909
3v1n0 added a commit to 3v1n0/authd that referenced this issue Jan 29, 2024
… mode

It's causing events to happen that we don't really need in this case
and also it's causing races.

See: charmbracelet/bubbletea#909
3v1n0 added a commit to 3v1n0/authd that referenced this issue Jan 29, 2024
… mode

It's causing events to happen that we don't really need in this case
and also it's causing races.

See: charmbracelet/bubbletea#909
3v1n0 added a commit to 3v1n0/authd that referenced this issue Jan 29, 2024
… mode

It's causing events to happen that we don't really need in this case
and also it's causing races.

See: charmbracelet/bubbletea#909
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 16, 2024
… mode

It's causing events to happen that we don't really need in this case
and also it's causing races.

See: charmbracelet/bubbletea#909
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 16, 2024
… mode

It's causing events to happen that we don't really need in this case
and also it's causing races.

See: charmbracelet/bubbletea#909
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 22, 2024
… mode

It's causing events to happen that we don't really need in this case
and also it's causing races.

See: charmbracelet/bubbletea#909
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 26, 2024
… mode

It's causing events to happen that we don't really need in this case
and also it's causing races.

See: charmbracelet/bubbletea#909
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant