Skip to content

fix a possible panic on cache#3670

Merged
jedevc merged 1 commit intomoby:masterfrom
imeoer:fix-panic-on-cache
Feb 24, 2023
Merged

fix a possible panic on cache#3670
jedevc merged 1 commit intomoby:masterfrom
imeoer:fix-panic-on-cache

Conversation

@imeoer
Copy link
Copy Markdown
Contributor

@imeoer imeoer commented Feb 24, 2023

newDesc.Annotations = nil
for _, k := range addAnnotations {
  newDesc.Annotations[k] = desc.Annotations[k]
}

The codes may cause buildkitd panic: assignment to entry in nil map

@imeoer
Copy link
Copy Markdown
Contributor Author

imeoer commented Feb 24, 2023

We encountered 1-5 panics per 30,000 builds, it's related to lzay layer with image ref annotation.

Copy link
Copy Markdown
Member

@jedevc jedevc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch 🎉

I think we want to make sure that the annotations map doesn't contain an empty map - it should either contain elements, or be nil.

@imeoer imeoer force-pushed the fix-panic-on-cache branch from 29b1893 to 04dff4b Compare February 24, 2023 11:36
@imeoer
Copy link
Copy Markdown
Contributor Author

imeoer commented Feb 24, 2023

Nice catch 🎉

I think we want to make sure that the annotations map doesn't contain an empty map - it should either contain elements, or be nil.

Thanks for the reply, fixed.

```
newDesc.Annotations = nil
for _, k := range addAnnotations {
  newDesc.Annotations[k] = desc.Annotations[k]
}
```

The codes may cause buildkitd panic: assignment to entry in nil map

Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
@imeoer imeoer force-pushed the fix-panic-on-cache branch from 04dff4b to 39bd8c6 Compare February 24, 2023 11:40
@jedevc jedevc merged commit 30eb659 into moby:master Feb 24, 2023
@tonistiigi tonistiigi mentioned this pull request Feb 28, 2023
@crazy-max crazy-max added this to the v0.11.4 milestone Feb 28, 2023
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