Skip to content

bug: concurrent manager.render calls interleave console output #2291

Closed

Description

@TerryHowe

What is the problem?

manager.render() in cmd/oras/internal/display/status/progress/manager.go can run concurrently with itself. It is called from two places:

  • the ticker goroutine started in manager.start() (every bufFlushDuration, plus a final render on renderDone)
  • Track, on the caller's goroutine, before a new status is appended

Both hold only m.lock.RLock(), so nothing stops two renders from overlapping. Copy, push and pull track blobs concurrently, so this happens in normal use.

#2290 fixes the data race on the status itself (Render now takes the status write lock). The console output is still unserialized, though. Each console.OutputTo / NewRow call is several separate writes to the terminal:

func (c *console) OutputTo(upCnt uint, str string) {
	_, _ = c.term.Write([]byte(Restore))
	_, _ = c.term.Write([]byte(aec.PreviousLine(upCnt).Apply(str)))
	_, _ = c.term.Write([]byte("\n"))
	_, _ = c.term.Write([]byte(aec.EraseLine(aec.EraseModes.Tail).String()))
}

When two renders overlap, their cursor restore / move-up / erase sequences interleave. A line can be written at the wrong offset or erased by the other render, which garbles the progress display. The reproduction test in #2289 had to wrap the mock console in a mutex for the same reason.

Proposed fix

Serialize rendering in the manager, for example with a dedicated renderLock sync.Mutex held for the whole of render(), or by doing all rendering from the ticker goroutine and having Track request a render instead of performing one. Once every frame is drawn by one goroutine at a time, the console needs no locking of its own.

A regression test could drive concurrent Track calls against a console that fails the test if OutputTo / NewRow calls overlap.

Related

Activity

  1. added
    bug
    on Oct 24, 2026
  2. kocaemre commented on Oct 24, 2026

    @kocaemre
    Contributor

    I can take this. I plan to add a focused concurrent-render regression that holds one console frame open and checks a second render cannot enter it, then serialize manager.render without changing status/console behavior. I will run the progress package race tests and broader display/status tests before a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions