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

[Backport 2.3-maintainence] Fix "unexpected EOF" errors on macOS #9495

Draft
wants to merge 1 commit into
base: 2.3-maintenance
Choose a base branch
from

Commits on Oct 31, 2023

  1. Move pseudoterminal slave open to child

    Hopefully this fixes "unexpected EOF" failures on macOS
    (#3137, #3605, #7242, #7702).
    
    The problem appears to be that under some circumstances, macOS
    discards the output written to the slave side of the
    pseudoterminal. Hence the parent never sees the "sandbox initialized"
    message from the child, even though it succeeded. The conditions are:
    
    * The child finishes very quickly. That's why this bug is likely to
      trigger in nix-env tests, since that uses a builtin builder. Adding
      a short sleep before the child exits makes the problem go away.
    
    * The parent has closed its duplicate of the slave file
      descriptor. This shouldn't matter, since the child has a duplicate
      as well, but it does. E.g. moving the close to the bottom of
      startBuilder() makes the problem go away. However, that's not a
      solution because it would make Nix hang if the child dies before
      sending the "sandbox initialized" message.
    
    * The system is under high load. E.g. "make installcheck -j16" makes
      the issue pretty reproducible, while it's very rare under "make
      installcheck -j1".
    
    As a fix/workaround, we now open the pseudoterminal slave in the
    child, rather than the parent. This removes the second condition
    (i.e. the parent no longer needs to close the slave fd) and I haven't
    been able to reproduce the "unexpected EOF" with this.
    
    (cherry picked from commit c536e00)
    edolstra authored and Ericson2314 committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    d2f4b8d View commit details
    Browse the repository at this point in the history