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

progress: fix sync issue in controller. #2641

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

sipsma
Copy link
Collaborator

@sipsma sipsma commented Feb 15, 2022

A panic was encountered where writes to progress status hit a nil
writer. While not easy to reproduce, this commit fixes a likely culprit.
The use of atomics in the controller was not safe against a race such as
the following:

  1. One goroutine calls Start, incrementing count but not yet setting
    writer.
  2. A second goroutine calls Start, increments count again but sees that
    count >1 and thus doesn't try to set writer.
  3. The second goroutine then calls Status, assuming the writer has been
    set, but the first goroutine still hasn't set the writer yet, causing
    a nil pointer exception.

This commit fixes that issue by just using a mutex instead of atomics.
It also adds a nil check for the writer just to be safe against panics
due to unknown issues in the future as missing a status update is much
better than buildkitd crashing.

Signed-off-by: Erik Sipsma [email protected]

This address the panic mentioned in the comment here, though the problem is unrelated to that PR: #2611 (comment)

A panic was encountered where writes to progress status hit a nil
writer. While not easy to reproduce, this commit fixes a likely culprit.
The use of atomics in the controller was not safe against a race such as
the following:
1. One goroutine calls Start, incrementing count but not yet setting
   writer.
2. A second goroutine calls Start, increments count again but sees that
   count >1 and thus doesn't try to set writer.
3. The second goroutine then calls Status, assuming the writer has been
   set, but the first goroutine still hasn't set the writer yet, causing
   a nil pointer exception.

This commit fixes that issue by just using a mutex instead of atomics.
It also adds a nil check for the writer just to be safe against panics
due to unknown issues in the future as missing a status update is much
better than buildkitd crashing.

Signed-off-by: Erik Sipsma <[email protected]>
@tonistiigi tonistiigi merged commit b36d860 into moby:master Feb 16, 2022
@aaronlehmann
Copy link
Collaborator

Will this be included in v0.10.0-rc2?

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

Successfully merging this pull request may close these issues.

3 participants