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

test: add coverage for child_process bounds check #11800

Closed
wants to merge 3 commits into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Mar 11, 2017

Make sure that monkey-patching process.execArgv doesn't cause
child_process to incorrectly munge execArgv in fork().

This basically is adding coverage for an index > 0 check (see comment
in this commit). Previously, that condition was never false in any of
the tests.

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)

test child_process

@Trott Trott added child_process Issues and PRs related to the child_process subsystem. test Issues and PRs related to the tests. labels Mar 11, 2017
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM. I think the link and ESLint comments could be dropped though.

@Trott
Copy link
Member Author

Trott commented Mar 12, 2017

Link and ESLint comments removed.

CI: https://ci.nodejs.org/job/node-test-pull-request/6810/

@Trott
Copy link
Member Author

Trott commented Mar 12, 2017

CI again with adjustment for Windows CLI: https://ci.nodejs.org/job/node-test-pull-request/6815/

@Trott
Copy link
Member Author

Trott commented Mar 14, 2017

Test still failing on Windows. Marking in progress until that gets sorted...

@Trott Trott added the wip Issues and PRs that are still a work in progress. label Mar 14, 2017
@Trott
Copy link
Member Author

Trott commented Mar 17, 2017

Sample failure on Windows: https://ci.nodejs.org/job/node-test-binary-windows/7064/RUN_SUBSET=1,VS_VERSION=vs2015,label=win2012r2/console

not ok 31 parallel/test-cli-eval
  ---
  duration_ms: 3.517
  severity: fail
  stack: |-
    
    assert.js:81
      throw new assert.AssertionError({
      ^
    AssertionError: '' === '42\n'
        at child.exec.common.mustCall (c:\workspace\node-test-binary-windows\RUN_SUBSET\1\VS_VERSION\vs2015\label\win2012r2\test\parallel\test-cli-eval.js:154:14)
        at c:\workspace\node-test-binary-windows\RUN_SUBSET\1\VS_VERSION\vs2015\label\win2012r2\test\common.js:473:15
        at ChildProcess.exithandler (child_process.js:238:7)
        at emitTwo (events.js:127:13)
        at ChildProcess.emit (events.js:215:7)
        at maybeClose (internal/child_process.js:893:16)
        at Socket.<anonymous> (internal/child_process.js:335:11)
        at emitOne (events.js:117:13)
        at Socket.emit (events.js:212:7)
        at Pipe._handle.close [as _onclose] (net.js:534:12)

@Trott
Copy link
Member Author

Trott commented Mar 17, 2017

So, Windows is not getting the output from console.log(42) but everything else is...

Perhaps related to nodejs/node-v0.x-archive#3871?

Maybe this is some "this OS blocks stdio but that one doesn't" thing? Maybe I'm reaching here...

Relevant code:

child.exec(
  `${nodejs} -e "process.execArgv = ['-e', 'console.log(42)', 'thirdArg'];
                 require('child_process').fork('${emptyFile}')"`,
  common.mustCall((err, stdout, stderr) => {
    assert.ifError(err);
    assert.strictEqual(stdout, '42\n');  // <- Raises AssertionError on Windows Only
    assert.strictEqual(stderr, '');
  }));

/cc @nodejs/platform-windows

Make sure that monkey-patching process.execArgv doesn't cause
child_process to incorrectly munge execArgv in fork().

This basically is adding coverage for an `index > 0` check (see Refs).
Previously, that condition was never false in any of the tests.

Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
@Trott
Copy link
Member Author

Trott commented Mar 17, 2017

Trying to squash everything into a single line to see if that makes a difference (which makes sense if so). New CI: https://ci.nodejs.org/job/node-test-pull-request/6909/

@Trott
Copy link
Member Author

Trott commented Mar 17, 2017

OMG, that did it! Landing soon...

Trott added a commit to Trott/io.js that referenced this pull request Mar 17, 2017
Make sure that monkey-patching process.execArgv doesn't cause
child_process to incorrectly munge execArgv in fork().

This basically is adding coverage for an `index > 0` check (see Refs).
Previously, that condition was never false in any of the tests.

PR-URL: nodejs#11800
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
@Trott Trott removed the wip Issues and PRs that are still a work in progress. label Mar 17, 2017
@Trott
Copy link
Member Author

Trott commented Mar 17, 2017

Landed in df69d95

@Trott Trott closed this Mar 17, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Mar 20, 2017
Make sure that monkey-patching process.execArgv doesn't cause
child_process to incorrectly munge execArgv in fork().

This basically is adding coverage for an `index > 0` check (see Refs).
Previously, that condition was never false in any of the tests.

PR-URL: nodejs#11800
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
Make sure that monkey-patching process.execArgv doesn't cause
child_process to incorrectly munge execArgv in fork().

This basically is adding coverage for an `index > 0` check (see Refs).
Previously, that condition was never false in any of the tests.

PR-URL: nodejs#11800
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
@MylesBorins
Copy link
Contributor

MylesBorins commented Apr 18, 2017

not landing cleanly on v6.x feel free to backport

edit: nvm got it

MylesBorins pushed a commit that referenced this pull request Apr 18, 2017
Make sure that monkey-patching process.execArgv doesn't cause
child_process to incorrectly munge execArgv in fork().

This basically is adding coverage for an `index > 0` check (see Refs).
Previously, that condition was never false in any of the tests.

PR-URL: #11800
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
MylesBorins pushed a commit that referenced this pull request Apr 19, 2017
Make sure that monkey-patching process.execArgv doesn't cause
child_process to incorrectly munge execArgv in fork().

This basically is adding coverage for an `index > 0` check (see Refs).
Previously, that condition was never false in any of the tests.

PR-URL: #11800
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
@MylesBorins MylesBorins mentioned this pull request Apr 19, 2017
andrew749 pushed a commit to michielbaird/node that referenced this pull request Jul 19, 2017
Make sure that monkey-patching process.execArgv doesn't cause
child_process to incorrectly munge execArgv in fork().

This basically is adding coverage for an `index > 0` check (see Refs).
Previously, that condition was never false in any of the tests.

PR-URL: nodejs/node#11800
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Refs: https://github.com/nodejs/node/blob/c67207731f16a78f6cae90e49c53b10728241ecf/lib/child_process.js#L76
@Trott Trott deleted the index-check branch January 13, 2022 22:45
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. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants