Skip to content

Getting EIO errors from nix build #15181

@jbms

Description

@jbms

Describe the bug

While running nix build inside a gvisor container, I intermittently see the following error:

error:
       … while waiting for the build environment for '/nix/store/58w946lldvwmy4isl79lz1vnl5qh23ls-sandbox-env.drv' to initialize (succeeded, previous messages: )

       error: reading a line: Input/output error  

From gvisor's strace I see that the cause of this error is a read from /dev/pts/ptmx that returns EIO. EIO is an expected error that occurs when the slave closes the file descriptor.

However, the code here:

return readLine(builderOut.get());

just uses the readLine function that does not correctly treat EIO as EOF.

std::string readLine(int fd, bool eofOk, char terminator)

When the code to use a pty was first added (#2878), special handling of EIO was also added. But it appears that the code for reading the output was later refactored to use readLine without taking into account the possibility of EIO.

Steps To Reproduce

I don't have a straightforward reproduction. I suspect that gvisor may be slower or otherwise have slightly different behavior that significantly increases the chance of this error occurring.

However, the cause seems clear and shouldn't require a reproduction.

Expected behavior

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions