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

Avoid nil pointer dereference when copying from image with no layers #2197

Merged
merged 5 commits into from
Jun 28, 2021

Commits on Jun 23, 2021

  1. Avoid nil pointer dereference when copying from image with no layers

    Fix this panic when copying from an image with no layers:
    
    ```
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0xdd8c17]
    
    goroutine 326 [running]:
    github.com/moby/buildkit/cache/contenthash.(*cacheManager).Checksum(0xc0005ec030, 0x1682c00, 0xc000842140, 0x0, 0x0, 0xc0005d4023, 0x1, 0x0, 0x0, 0x0, ...)
    	/src/cache/contenthash/checksum.go:95 +0x37
    github.com/moby/buildkit/cache/contenthash.Checksum(0x1682c00, 0xc000842140, 0x0, 0x0, 0xc0005d4023, 0x1, 0x0, 0x0, 0x0, 0x0, ...)
    	/src/cache/contenthash/checksum.go:59 +0xd5
    github.com/moby/buildkit/solver/llbsolver.NewContentHashFunc.func1.1(0x0, 0x4425d6)
    	/src/solver/llbsolver/result.go:59 +0x20a
    golang.org/x/sync/errgroup.(*Group).Go.func1(0xc00056a360, 0xc000594510)
    	/src/vendor/golang.org/x/sync/errgroup/errgroup.go:57 +0x59
    created by golang.org/x/sync/errgroup.(*Group).Go
    	/src/vendor/golang.org/x/sync/errgroup/errgroup.go:54 +0x66
    ```
    
    When the path is "/", we allow it because it's a noop.
    
    Based on moby#2185
    
    Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
    aaronlehmann committed Jun 23, 2021
    Configuration menu
    Copy the full SHA
    799175f View commit details
    Browse the repository at this point in the history
  2. Add test for copying from scratch

    Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
    aaronlehmann committed Jun 23, 2021
    Configuration menu
    Copy the full SHA
    e70f855 View commit details
    Browse the repository at this point in the history
  3. Check that scratch is mounted as empty dir

    Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
    aaronlehmann committed Jun 23, 2021
    Configuration menu
    Copy the full SHA
    8f2fd48 View commit details
    Browse the repository at this point in the history

Commits on Jun 26, 2021

  1. Make error message consistent when layer is empty

    Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
    aaronlehmann committed Jun 26, 2021
    Configuration menu
    Copy the full SHA
    c1a48b7 View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2021

  1. Test with tonistiigi/test:nolayers as well

    Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
    aaronlehmann committed Jun 27, 2021
    Configuration menu
    Copy the full SHA
    a018bf5 View commit details
    Browse the repository at this point in the history