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

archive: fix race condition in cmdStream #39860

Merged
merged 1 commit into from Sep 12, 2019
Merged

Commits on Sep 11, 2019

  1. archive: fix race condition in cmdStream

    There is a race condition in pkg/archive when using `cmd.Start` for pigz
    and xz where the `*bufio.Reader` could be returned to the pool while the
    command is still writing to it, and then picked up and used by a new
    command.
    
    The command is wrapped in a `CommandContext` where the process will be
    killed when the context is cancelled, however this is not instantaneous,
    so there's a brief window while the command is still running but the
    `*bufio.Reader` was already returned to the pool.
    
    wrapReadCloser calls `cancel()`, and then `readBuf.Close()` which
    eventually returns the buffer to the pool. However, because cmdStream
    runs `cmd.Wait` in a go routine that we never wait for to finish, it is
    not safe to return the reader to the pool yet.  We need to ensure we
    wait for `cmd.Wait` to finish!
    
    Signed-off-by: Stephen Benjamin <stephen@redhat.com>
    stbenjam committed Sep 11, 2019
    Copy the full SHA
    89dd10b View commit details
    Browse the repository at this point in the history