Skip to content

child_process: check execFile and fork args - #2667

Closed
jasnell wants to merge 2 commits into
nodejs:masterfrom
jasnell:child_process_argument_checking
Closed

child_process: check execFile and fork args#2667
jasnell wants to merge 2 commits into
nodejs:masterfrom
jasnell:child_process_argument_checking

Conversation

@jasnell

@jasnell jasnell commented Sep 2, 2015

Copy link
Copy Markdown
Member

Port of joyent/node commits:

Pull over test-child-process-spawn-typeerror.js from v0.12, replacing
the existing test in master. The new test includes a broader set of
tests on the various arg choices and throws.

@rvagg @Fishrock123 @trevnorris @nodejs/tsc

See: #2515

@Fishrock123 Fishrock123 added the child_process Issues and PRs related to the child_process subsystem. label Sep 2, 2015

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.

Can these be broken into separate const and let variables.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes. I'd prefer that actually. Just literally pulled this over straight from what is in v0.12.

@jasnell

jasnell commented Sep 2, 2015

Copy link
Copy Markdown
Member Author

Ok. @thefourtheye @cjihrig ... nits in the test fixed

@jasnell jasnell added this to the 4.0.0 milestone Sep 2, 2015
Comment thread lib/child_process.js

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.

Is it possible that both of these fail? If neither is supposed to then mind adding a final else with something like throw new Error('UNREACHABLE'); or the like?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, the fall through on this particular one is required for the next check. Overall, the currently behavior in v0.12 (and this port of that code) is really just a half measure. We're not actually doing a complete check. For instance, execFile('ls',{a:1},'test') goes through without a throw even tho a string is passed in for the callback. Internally, execFile just acts as if the callback wasn't provided at all. Likewise, execFile('ls',[], 'test', function() {}) does not throw either. Nor does execFile('ls',[],'test','test'). The only type that is actually checked is the args, so that if you pass in execFile('ls', 'test'), a TypeError will throw.

Given that this is exactly how it behaves in v0.12 currently (for better or worse), I'd be more inclined to land it as is so we can close the convergence loop first, then make additional improvements separately.

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.

Thanks for the explanation. Sounds like a good plan. Maybe put a todo comment in the code, or we can open an issue for what you've explained and land the fix in a future master. From how you've described it, there is ambiguity with argument parsing.

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.

Can we pull the common pos < arguments.length check outside?

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.

not sure it's worth it to add the nested conditional. performance-wise there's no measurable gain.

so basically, I don't think it's necessary but I'm also not opposed to the change.

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.

Right, but it will improve the readability and reduce redundant checks. It's just a suggestion I am okay without that as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Given that we'll need to revisit this anyway later. Let's leave it as is
for now and do any additional cleanups in the next round.
On Sep 2, 2015 10:29 PM, "thefourtheye" notifications@github.com wrote:

In lib/child_process.js
#2667 (comment):

@@ -118,18 +120,26 @@ exports.execFile = function(file /, args, options, callback/) {
env: null
};

  • // Parse the parameters.
  • // Parse the optional positional parameters.
  • var pos = 1;
  • if (pos < arguments.length && Array.isArray(arguments[pos])) {
  • args = arguments[pos++];
  • } else if (pos < arguments.length && arguments[pos] == null) {
  • pos++;
  • }

Right, but it will improve the readability and reduce redundant checks.
It's just a suggestion I am okay without that as well.


Reply to this email directly or view it on GitHub
https://github.com/nodejs/node/pull/2667/files#r38614155.

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.

Cool. Since we introduced new exception, this would be semver-major?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Technically. But this is already in v0.12 and is part of the convergence work. It will land in master and will be cherry picked to v4.x

@Fishrock123

Copy link
Copy Markdown
Contributor

@jasnell master is implicit. That label was for stuff back when master wasn't the primary branch.

Port of joyent/node commits:

 * nodejs/node-v0.x-archive@e17c5a7
 * nodejs/node-v0.x-archive@70dafa7

Pull over test-child-process-spawn-typeerror.js from v0.12, replacing
the existing test in master. The new test includes a broader set of
tests on the various arg choices and throws.
Fixing multiple style nits in the test pulled over from v0.12.
@jasnell
jasnell force-pushed the child_process_argument_checking branch from aa0f2c0 to 7e5710a Compare September 3, 2015 03:21
@jasnell

jasnell commented Sep 3, 2015

Copy link
Copy Markdown
Member Author

Rebased.

@rvagg rvagg mentioned this pull request Sep 3, 2015
10 tasks

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.

const child

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not seeing this edit as being critical to land this. can do this in the next pass.

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.

Sure. No problem. We can actually remove the variable and directly attach the even handler.

@thefourtheye

Copy link
Copy Markdown
Contributor

LGTM. But I would prefer waiting till we get one or more of them. Meanwhile let's have a CI run.

@jasnell

jasnell commented Sep 3, 2015

Copy link
Copy Markdown
Member Author

Will get a CI run and get this landed in the morning. This is on the short list of must-do's for v4.0.0 so we definitely need to get this landed soon.

CI run started here: https://ci.nodejs.org/job/node-test-pull-request/240/

@jasnell

jasnell commented Sep 3, 2015

Copy link
Copy Markdown
Member Author

CI is looking all green except for an unrelated jenkins failure on one of the windows boxes. The arm tests are still running.

@thefourtheye

Copy link
Copy Markdown
Contributor

@jasnell That windows slave went offline during the build. Can we give it one more try. cc @nodejs/build

@jasnell

jasnell commented Sep 3, 2015

Copy link
Copy Markdown
Member Author

Given that the CI will run when I go to land the PR, I'll wait for that. For now, it's off to bed for me.

@thefourtheye

Copy link
Copy Markdown
Contributor

@jasnell No problem. I'll start one more run when the current one finishes. Night night :-)

@cjihrig

cjihrig commented Sep 3, 2015

Copy link
Copy Markdown
Contributor

LGTM

@thefourtheye

Copy link
Copy Markdown
Contributor

@jasnell

jasnell commented Sep 3, 2015

Copy link
Copy Markdown
Member Author

Queued up to land. There are four builds lined up before this one so it may take a while.

@orangemocha

Copy link
Copy Markdown
Contributor

After consulting with @jasnell , I cancelled the CI run and re-queued it in https://ci.nodejs.org/job/node-accept-pull-request/123/ (pending), so that it has a better chance of succeeding if hopefully #2679 lands first.

jasnell added a commit that referenced this pull request Sep 3, 2015
Port of joyent/node commits:

 * nodejs/node-v0.x-archive@e17c5a7
 * nodejs/node-v0.x-archive@70dafa7

Pull over test-child-process-spawn-typeerror.js from v0.12, replacing
the existing test in master. The new test includes a broader set of
tests on the various arg choices and throws.

Reviewed-By: trevnorris - Trevor Norris <trevnorris@nodejs.org>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: thefourtheye - Sakthipriyan Vairamani
PR-URL: #2667
Fixes: #2515
@jasnell

jasnell commented Sep 3, 2015

Copy link
Copy Markdown
Member Author

Landed (manually) in 107cbd6 (cc @rvagg @orangemocha )

@jasnell jasnell closed this Sep 3, 2015
@thefourtheye

Copy link
Copy Markdown
Contributor

@jasnell you missed my email in the commit log :D

@jasnell

jasnell commented Sep 3, 2015

Copy link
Copy Markdown
Member Author

Ugh. Sorry about that. That's why we like automated processes! (When they
work lol)
On Sep 3, 2015 11:36 AM, "thefourtheye" notifications@github.com wrote:

@jasnell https://github.com/jasnell you missed my email in the commit
log :D


Reply to this email directly or view it on GitHub
#2667 (comment).

@thefourtheye

Copy link
Copy Markdown
Contributor

No problem :-) Glad that the patch landed at the earliest.

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