Skip to content

Conversation

Kelmar
Copy link

@Kelmar Kelmar commented May 23, 2016

Fix for Windows Segfault with missing arguments.

Platform: Windows
Arch: x64
Compiler: VC2015

When specifying a parameter that requires an additional argument on the
command line, node would segfault. This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.

Take two of the fix, based on feedback from @addaleax

Arch: x64
Compiler: VC2015

When specifing a parameter that requries an additional argument on the
command line, node would segfault.  This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label May 23, 2016
@addaleax addaleax mentioned this pull request May 23, 2016
@addaleax
Copy link
Member

The code changes looks good. I don’t know if you’ve read your way through the contributing guidlines, but a couple of things things that would be awesome here:

  • Ideally, there would be a regression test added in this PR. You can take a look at e.g. test/parallel/test-cli-eval.js and see if you can add a similar test there, where you invoke only node -e.
  • The commit message would need to look a bit more like specified in the guidelines, i.e. there would be a subject line that says in a very short form what was changed here.

@thefourtheye This approach looks good to you?

@addaleax addaleax added the lib / src Issues and PRs related to general changes in the lib or src directory. label May 23, 2016
@cjihrig
Copy link
Contributor

cjihrig commented May 23, 2016

@addaleax did you mean to close this?

@cjihrig
Copy link
Contributor

cjihrig commented May 23, 2016

Sorry, confused this with the other PR with the same title.

@mscdex mscdex added windows Issues and PRs related to the Windows platform. and removed lib / src Issues and PRs related to general changes in the lib or src directory. labels May 24, 2016
@bnoordhuis
Copy link
Member

LGTM but the commit log should conform to the style guide and a regression test would be nice.

This bug is over four years old. It's amusing and a little odd it managed to go undiscovered for so long.

@Kelmar
Copy link
Author

Kelmar commented May 24, 2016

@addaleax I'll get those changes in as soon as I am able; really I just ran across it and was like, "that seems like an easy fix." But yea, I'm glad to see there are regression tests. :)

@addaleax
Copy link
Member

@Kelmar yeah, don’t worry. Adding a regression test can also be done later and/or by someone else if you don’t find the time – again, if you need anything finding your way around here, just ask. :)

@Kelmar
Copy link
Author

Kelmar commented May 24, 2016

@addaleax Done! I'll read over the contributing documentation now. I hope you find this fix helpful. :)

// Missing argument should not crash
child.exec(nodejs + ' -e', function (status, stdout, stderr) {
assert.notStrictEqual(status, null);
assert.equal(status.code, 9);
Copy link
Member

Choose a reason for hiding this comment

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

nit: It’s generally preferred to use assert.strictEqual over assert.equal

@Kelmar
Copy link
Author

Kelmar commented May 24, 2016

Done!

@addaleax
Copy link
Member

LGTM up to assert.equal -> assert.strictEqual.

Thank you for the report + bugfix! Really funny this went unnoticed so long.

@Fishrock123 Fishrock123 changed the title Platform: Windows Fix windows segfault May 24, 2016
@@ -66,6 +66,12 @@ child.exec(nodejs + ' --eval "require(\'./test/parallel/test-cli-eval.js\')"',
assert.equal(status.code, 42);
});

// Missing argument should not crash
child.exec(nodejs + ' -e', function(status, stdout, stderr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As the assertion happens within the callback, its better to use common.mustCall

@thefourtheye
Copy link
Contributor

LGTM + nits.

@addaleax
Copy link
Member

ping @Kelmar … There are only two things left to address here (commit log should conform to the style guide + Use strictEqual), that should be all and then this can be landed.

@Kelmar
Copy link
Author

Kelmar commented Jun 6, 2016

@addaleax Okay, I believe this should fix everything up to your submission guide lines. Please let me know if I've missed anything or didn't interpret the instructions correctly. :)

@addaleax
Copy link
Member

addaleax commented Jun 6, 2016

@Kelmar There’s actually one point by @thefourtheye still open, namely that the callback for child.exec should be wrapped in common.mustCall(), like child.exec(…, common.mustCall(function(status, stdout, stderr) { … })) to make sure that the callback actually gets called.

I realize that the other tests in the file don’t set a good example here, but it would still be great if you could update your added test with that.

@addaleax
Copy link
Member

@addaleax
Copy link
Member

Landed in 5bddc9a, fixed commit log and nit on landing.

@Kelmar Thanks for your contribution!

@addaleax addaleax closed this Jun 20, 2016
addaleax pushed a commit that referenced this pull request Jun 20, 2016
When specifing a parameter that requries an additional argument on the
command line, node would segfault.  This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.

Adding unit test for crash on missing arguments.

PR-URL: #6938
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
evanlucas pushed a commit that referenced this pull request Jun 27, 2016
When specifing a parameter that requries an additional argument on the
command line, node would segfault.  This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.

Adding unit test for crash on missing arguments.

PR-URL: #6938
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@Fishrock123 Fishrock123 mentioned this pull request Jun 27, 2016
@Fishrock123 Fishrock123 mentioned this pull request Jul 5, 2016
MylesBorins pushed a commit that referenced this pull request Jul 11, 2016
When specifing a parameter that requries an additional argument on the
command line, node would segfault.  This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.

Adding unit test for crash on missing arguments.

PR-URL: #6938
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 11, 2016
When specifing a parameter that requries an additional argument on the
command line, node would segfault.  This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.

Adding unit test for crash on missing arguments.

PR-URL: #6938
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
When specifing a parameter that requries an additional argument on the
command line, node would segfault.  This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.

Adding unit test for crash on missing arguments.

PR-URL: #6938
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
When specifing a parameter that requries an additional argument on the
command line, node would segfault.  This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.

Adding unit test for crash on missing arguments.

PR-URL: #6938
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jul 12, 2016
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
When specifing a parameter that requries an additional argument on the
command line, node would segfault.  This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.

Adding unit test for crash on missing arguments.

PR-URL: #6938
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
When specifing a parameter that requries an additional argument on the
command line, node would segfault.  This appears to be specific to
Windows, adjusted command line argument parsing to hold a nullptr
terminal.

Adding unit test for crash on missing arguments.

PR-URL: #6938
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants