Repository navigation
fix: ensure that file descriptors 0/1/2 are opened at startup - #15555
Conversation
|
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
|
Maybe take a look at node's |
|
Is there anything more that I should do to proceed? Github says that some automatic checks have failed, but I'm not sure what I can do about this. Or should I just patiently wait for a review? |
It looks like node |
Not quite. In the quoted code ABORT is called only if the error is not EBADF, or reopening with /dev/null fails. Both cases represent a "pathological" scenario where proceeding is not a good idea. |
|
Ohhhh, I see, it's just "cleverly" written code that calls |
nornagon
left a comment
There was a problem hiding this comment.
Do we also need to do this on windows, as node does?
Lastly, I'm not sure if you can re-target a PR, but generally we base changes on master and then backport them to release branches after they land there. It'd be great to get a version of this that targets master.
POSIX guarantees that open() always returns the lowest available file descriptor. If * Assuming no signal handlers or threads create file descriptors in the time window between the fstat() and the open() calls. This code isn't susceptible to that. It runs at very early startup, when there are no threads or signal handlers yet. |
I don't know much about windows, but it seems that libuv on windows doesn't have the same problem (example: https://github.com/libuv/libuv/blob/4c2dcca27b80945d6b7063f0ea031b8a75a46a52/src/win/tty.c#L187-L203). |
|
Please rebase onto master so that the appveyor tests will run! 🙇 |
Ah, so that's what the errors were about. Now lint is complaining about an #elif line that I didn't touch in my commit. Should I fix this as well? I assumed it's a bad idea to add unrelated whitespace-only changes to a commit. |
|
Yes, please fix the lint errors. I'm not totally sure why that line isn't causing failures in Looks like there are some legitimate failures on Windows, too, which I think you can fix by just hiding this code behind |
This fixes an issue where the gpu subprocess was writing messages to a random pipe or socket. The standard file desciptors are closed in chromium's subprocesses because of an unfortunate interaction with libuv's tty handling code leaving them with the FD_CLOEXEC flag.
|
Is there anything I can do about the remaining test failures? These don't seem related to my changesin any way... |
|
I agree that those failures seem unrelated. I'll rerun the CI jobs to see if they finish cleanly, if not then I think we're probably OK to merge. |
|
It seems that there's another unrelated test failure. Do other PR's pass the test suite? |
|
/trop run backport |
|
The backport process for this PR has been manually initiated, here we go! :D |
|
I was unable to backport this PR to "3-0-x" cleanly; |
|
I have automatically backported this PR to "4-0-x", please check out #15763 |
|
/trop run backport |
|
The backport process for this PR has been manually initiated, here we go! :D |
|
I was unable to backport this PR to "3-0-x" cleanly; |
|
I was unable to backport this PR to "3-1-x" cleanly; |
|
Which versions of electron (specifically 3.0.X) contains this pr? |
…on#15555) * fix: ensure that file descriptors 0/1/2 are opened at startup This fixes an issue where the gpu subprocess was writing messages to a random pipe or socket. The standard file desciptors are closed in chromium's subprocesses because of an unfortunate interaction with libuv's tty handling code leaving them with the FD_CLOEXEC flag. * style: fix lint warnings
Description of Change
Libuv has a nasty mis-feature (libuv/libuv#2062), where it marks the standard input/output/error tty streams with the close-on-exec flag. In effect, when the chromium gpu process is spawned, it starts with the fd's 0,1,2 closed. These are reused for other purposes, and if any message is output on stdout/stderr, it ends up in an unrelated socket, pipe or file which generally messes things up. This is the root cause of at least two issues: #14246 and #12937, and possibly these (duplicates) as well: #13415, #14954, #14697
The proper place to fix this would be in libuv, but the upstream developers insist that the current behaviour is right. My change introduces a workaround which checks the standard fds at startup, and reopens them as /dev/null if missing. Feel free to point me to a better solution.
Checklist
npm testpassesIn my environment, npm test on the 3-0-x branch fails on 5 tests.
My commit doesn't introduce any more failures.
Release Notes
Notes: Fixed a freeze when using the GPU in some configurations.