Skip to content

panic on unexpected EOF during pull #1407

Closed

Description

@codegod100
thread 'tokio-runtime-worker' panicked at ostree-ext/src/container/unencapsulate.rs:217:24:
Decompressor::finish MUST be called: unexpected end of file
Fetching layers ██░░░░░░░░░░░░░░░░░░ 9/75 
 └ Fetching █████░░░░░░░░░░░░░░░ 20.57 MiB/69.38 MiB (0 B/s) ostree chunk a15970c0d9d743e9f5fbd                                                                                                                             
  zsh: IOT instruction  sudo bootc switch ghcr.io/codegod100/template:latest

Activity

  1. cgwalters commented on Jul 15, 2025

    @cgwalters
    Member

    Decompressor::finish MUST be called

    So we got here

    self._finish().expect("Decompressor::finish MUST be called")

    unexpected end of file

    If all that happened here was an unexpected EOF we should definitely not panic on that. I think we probably need to just drop this panic because on error paths exactly like this it may be hit. Ultimately the calling code should be verifying checksums and the like for integrity.

    And eventually we should switch to podman-container-tools/skopeo#2601

  2. changed the title [-]error while running bootc switch[/-] [+]panic on unexpected EOF during pull[/+] on Jul 15, 2025
  3. added
    triaged
    area/client
    on Jul 15, 2025
  4. jeckersb commented on Jul 15, 2025

    @jeckersb
    Collaborator

    If I had to guess, there's probably an error case somewhere that we missed that should be updated to clear out the decompressor when we get EOF like that. I would be extremely wary to remove that panic, the comment above there sums up why.

  5. jeckersb commented on Jul 15, 2025

    @jeckersb
    Collaborator

    Actually looking at it again, the unexpected end of file is coming from

    let n = std::io::copy(&mut self.inner, &mut sink)?;

    So I'm guessing something is wrong with the state of self.inner just based on the assumption that a std::io::sink() can't give unexpected EOF.

  6. jeckersb commented on Jul 16, 2025

    @jeckersb
    Collaborator

    I think this is probably coming from the gzip stream

    https://github.com/rust-lang/flate2-rs/blob/7145603d57b7795c51d8674824163d6d685c9733/src/gz/mod.rs#L243

    (give or take)

    Which is easily reproduced by just feeding it an empty src:

    diff --git i/ostree-ext/src/container/unencapsulate.rs w/ostree-ext/src/container/unencapsulate.rs
    index 81eb90c7..21f7c23d 100644
    --- i/ostree-ext/src/container/unencapsulate.rs
    +++ w/ostree-ext/src/container/unencapsulate.rs
    @@ -362,4 +362,11 @@ mod tests {
             let d = Decompressor::new(&oci_image::MediaType::ImageLayer, empty).unwrap();
             drop(d)
         }
    +
    +    #[test]
    +    fn test_drop_decompressor_with_incomplete_gzip_data() {
    +        let empty = std::io::empty();
    +        let d = Decompressor::new(&oci_image::MediaType::ImageLayerGzip, empty).unwrap();
    +        drop(d)
    +    }
     }
    

    =>

    ---- container::unencapsulate::tests::test_drop_decompressor_with_incomplete_gzip_data stdout ----
    
    thread 'container::unencapsulate::tests::test_drop_decompressor_with_incomplete_gzip_data' panicked at ostree-ext/src/container/unencapsulate.rs:217:24:
    Decompressor::finish MUST be called: unexpected end of file
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

    So really the problem is that when we finish the decompressor, we want to empty out the underlying pipe and ignore anything happening with the actual decompression. But the way things are currently structured, that's not accessible. We'd need some way to into_inner() on the GzDecoder or similar.

  7. added 3 commits that reference this issue on Jul 16, 2025
    147c387
    cc52892
    75d5e71
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

    area/clienttriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions