Getting write errors on stdout after invoking /usr/bin/ibtool

I’m really confused. I’m seeing an issue right now, reproducible on multiple computers, where in the Nix build environment (either a normal build or a nix-shell), after invoking /usr/bin/ibtool (even just /usr/bin/ibtool --version), invoking the Nix yes fails after a few hundred lines with yes: standard output: Resource temporarily unavailable. Anything else that emits a reasonable amount of output fails with a similar error (e.g. type genericBuild usually fails). /usr/bin/yes doesn’t fail but Nix tools do. If I create an interactive subshell (e.g. run bash), the problem goes away, even after I exit the subshell, but short of that, non-trivial amounts of output produce write errors. Even pagers like man bash produce truncated output.

I did recently upgrade my Xcode from Xcode 10.3 to Xcode 11 GM (which is where /usr/bin/ibtool comes from), which explains why I’m seeing a behavior difference right now, but what I can’t figure out is what the heck is going on. I can’t reproduce this outside of the Nix environment. What could running /usr/bin/ibtool possibly be doing to trigger this, why does it only happen in Nix, and why does spawning an interactive subshell fix it?

Is it possible that ibtool marks stdout as nonblocking, and that this setting somehow affects the spawning shell? How would I properly test for this?

I was about to publish this and I discovered a new twist. Bash’s read builtin fails instantly in this scenario as well:

> read
bash: read: read error: 0: Resource temporarily unavailable

Again, spawning an interactive subshell fixes it.

Finally reproduced it outside of the Nix environment, by running Nix bash. nixpkgs.bash reproduces it if I don’t let control return to the REPL; nixpkgs.bashInteractive reproduces it even with the REPL. This line will do it without interactivity:

nix run nixpkgs.bash -c bash -c "/usr/bin/ibtool --version; read"

Wow yeah ok. I wrote a quick C program that tells me if fd 1 is marked O_NONBLOCK and when using Nix bash, stdout is nonblocking after running /usr/bin/ibtool. When using macOS-provided bash or when using a shell like fish, stdout remains blocking after ibtool exits.

Actually macOS-provided bash is reproducing this as well as long as I don’t let control return to the REPL. And I also just confirmed on another computer that the behavior occurs with Xcode 10.3 as well, so it’s not due to an Xcode change, which suggests it must be due to a recent Nix change because a package that used to compile (macvim) now fails. Though I’m not sure on this either as nix-channel --rollback doesn’t fix the problem.

On, mobile, sorry for brevity.

I wonder if this is related to

I tried to hunt this down a while ago, and I’m not 100% certain the title of that issue is correct.

No, that’s something else.