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

child_process: fix handle passing with large payloads #14588

Closed
wants to merge 2 commits into from

Conversation

addaleax
Copy link
Member

@addaleax addaleax commented Aug 2, 2017

Fix situations in which the handle passed along with a message
that has a large payload and can’t be read entirely by a single
recvmsg() call isn’t associated with the message to which it
belongs.

Fixes: #13778

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)

child_process

@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Aug 2, 2017
process.on('message', common.mustCall(({ payload: received }, handle) => {
assert.strictEqual(payload, received);
assert(handle instanceof net.Socket);
process.send({ payload: received }, handle);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: use { payload } for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lpinca done!

} else {
handleMessage(message, undefined, false);
}

pendingHandle = null;
Copy link
Member

Choose a reason for hiding this comment

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

This looks incorrect: it clears the variable on the first iteration but what if the NODE_HANDLE message is not in the first chunk? I would have expected to see this assignment in the if (message.cmd === 'NODE_HANDLE') { block.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I think that makes more sense – done.

@addaleax addaleax force-pushed the cluster-large-message-handle branch 2 times, most recently from 8f3c0e0 to 2f65c3f Compare August 2, 2017 09:41
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

LGTM. Maybe add an assert that checks pendingHandle is null again after the loop.

@jasnell
Copy link
Member

jasnell commented Aug 3, 2017

Fix situations in which the handle passed along with a message
that has a large payload and can’t be read entirely by a single
`recvmsg()` call isn’t associated with the message to which it
belongs.

Fixes: nodejs#13778
@addaleax addaleax force-pushed the cluster-large-message-handle branch from 2f65c3f to be0fed0 Compare August 7, 2017 12:05
@addaleax
Copy link
Member Author

addaleax commented Aug 7, 2017

So … the test here isn’t even flaky on Windows, it’s just always failing. Would anybody in @nodejs/platform-windows have a chance to look at what’s going wrong?

@addaleax
Copy link
Member Author

addaleax commented Aug 7, 2017

Tried something new with help from @tniessen

CI: https://ci.nodejs.org/job/node-test-commit/11599/
Stress: https://ci.nodejs.org/job/node-stress-single-test/1366/

@jasnell
Copy link
Member

jasnell commented Aug 8, 2017

Landed in 611851d

@jasnell jasnell closed this Aug 8, 2017
addaleax added a commit that referenced this pull request Aug 9, 2017
Fix situations in which the handle passed along with a message
that has a large payload and can’t be read entirely by a single
`recvmsg()` call isn’t associated with the message to which it
belongs.

PR-URL: #14588
Fixes: #13778
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
@addaleax addaleax deleted the cluster-large-message-handle branch August 10, 2017 19:26
@MylesBorins
Copy link
Contributor

This is going to need a manual backport for both v4 and v6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants