From 3234834f63b423b716e0f20bf68314d81fc1beb0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 6 Sep 2026 09:55:31 +0200 Subject: [PATCH] Guard View.LinesHeight against a concurrent write The count comes from the view's buffer, which a rendering task appends to on its own goroutine, so reading it without the write mutex is a data race. Nobody called it until now, which is why nothing has tripped over it; the next commit does, from the UI thread while a render is still loading. Co-authored-by: Claude Opus 5 (1M context) --- pkg/gocui/view.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/gocui/view.go b/pkg/gocui/view.go index 42a087dce..060079f50 100644 --- a/pkg/gocui/view.go +++ b/pkg/gocui/view.go @@ -2063,6 +2063,9 @@ func (v *View) ViewBufferLines() []string { // LinesHeight is the count of view lines (i.e. lines excluding wrapping) func (v *View) LinesHeight() int { + v.writeMutex.Lock() + defer v.writeMutex.Unlock() + return len(v.buf.lines) }