Skip to content

lib: setup IPC channel before console - #16562

Closed
seishun wants to merge 0 commit into
nodejs:masterfrom
seishun:ipc-einval
Closed

lib: setup IPC channel before console#16562
seishun wants to merge 0 commit into
nodejs:masterfrom
seishun:ipc-einval

Conversation

@seishun

@seishunseishun commented Oct 27, 2017

Copy link
Copy Markdown
Contributor

Initializing IOCP on the same fd twice can fail on Windows.
Consequently, if the IPC channel uses fd 1 or 2 and the console is setup
first, writing to the IPC channel will fail.

Fixes: #16141

Will add a test if there are no objections to this approach.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

lib

@nodejs-github-botnodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Oct 27, 2017

@addaleaxaddaleax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no way to write a test for this, can you add a comment so that nobody accidentally moves this around again?

@refack

Copy link
Copy Markdown
Contributor

AFAICT a regression test is simple:

d:\code\node-master$ setNODE_CHANNEL_FD=0
d:\code\node-master$ node
child_process.js:107
p.open(fd);
^
Error: EINVAL: invalid argument, uv_pipe_open
at Object.exports._forkChild (child_process.js:107:5)
at Object.setupChannel (internal/process.js:244:8)
at startup (bootstrap_node.js:69:16)
at bootstrap_node.js:608:3
d:\code\node-master$ setNODE_CHANNEL_FD=
d:\code\node-master$

@cjihrigcjihrig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but a test would be great.

@seishun

Copy link
Copy Markdown
ContributorAuthor

Added a test. @cjihrig@addaleax@refack PTAL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

// make sure `fd[1]` has not been opened for `console`

Comment threadlib/internal/bootstrap_node.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

// This needs to happen after `_process.setupChannel()`

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a regression test and git blame, so I don't think it's necessary (or even useful in this form tbh).

@bnoordhuisbnoordhuis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM FWIW

@seishun

Copy link
Copy Markdown
ContributorAuthor

@cjihrig

Copy link
Copy Markdown
Contributor

Still LGTM, thanks.

@seishun

Copy link
Copy Markdown
ContributorAuthor

The failure seems unrelated.

seishun added a commit that referenced this pull request Oct 29, 2017
Initializing IOCP on the same fd twice can fail on Windows.
Consequently, if the IPC channel uses fd 1 or 2 and the console is setup
first, writing to the IPC channel will fail.
PR-URL: #16562Fixes: #16141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@seishunseishun closed this Oct 29, 2017
@seishun

Copy link
Copy Markdown
ContributorAuthor

Landed in 403ccb6.

@seishun
seishun deleted the ipc-einval branch October 29, 2017 19:29
gibfahn pushed a commit that referenced this pull request Oct 30, 2017
Initializing IOCP on the same fd twice can fail on Windows.
Consequently, if the IPC channel uses fd 1 or 2 and the console is setup
first, writing to the IPC channel will fail.
PR-URL: #16562Fixes: #16141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
gibfahn pushed a commit that referenced this pull request Oct 30, 2017
Initializing IOCP on the same fd twice can fail on Windows.
Consequently, if the IPC channel uses fd 1 or 2 and the console is setup
first, writing to the IPC channel will fail.
PR-URL: #16562Fixes: #16141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
gibfahn pushed a commit that referenced this pull request Oct 31, 2017
Initializing IOCP on the same fd twice can fail on Windows.
Consequently, if the IPC channel uses fd 1 or 2 and the console is setup
first, writing to the IPC channel will fail.
PR-URL: #16562Fixes: #16141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@gibfahngibfahn mentioned this pull request Oct 31, 2017
Qard pushed a commit to ayojs/ayo that referenced this pull request Nov 2, 2017
Initializing IOCP on the same fd twice can fail on Windows.
Consequently, if the IPC channel uses fd 1 or 2 and the console is setup
first, writing to the IPC channel will fail.
PR-URL: nodejs/node#16562Fixes: nodejs/node#16141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Qard pushed a commit to ayojs/ayo that referenced this pull request Nov 2, 2017
Initializing IOCP on the same fd twice can fail on Windows.
Consequently, if the IPC channel uses fd 1 or 2 and the console is setup
first, writing to the IPC channel will fail.
PR-URL: nodejs/node#16562Fixes: nodejs/node#16141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins

Copy link
Copy Markdown
Contributor

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

@seishun

Copy link
Copy Markdown
ContributorAuthor

No need to backport since #16141 isn't an issue on v6.x AFAIK.

addaleax pushed a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
Initializing IOCP on the same fd twice can fail on Windows.
Consequently, if the IPC channel uses fd 1 or 2 and the console is setup
first, writing to the IPC channel will fail.
PR-URL: nodejs/node#16562Fixes: nodejs/node#16141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib / srcIssues and PRs related to general changes in the lib or src directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error "write EINVAL"

8 participants

@seishun@refack@cjihrig@MylesBorins@bnoordhuis@jasnell@addaleax@nodejs-github-bot