Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
child_process: check accessing a null stderr#6877
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
robertchiras commented May 19, 2016 • edited by eljefedelrodeodeljefe
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by eljefedelrodeodeljefe
Uh oh!
There was an error while loading. Please reload this page.
cjihrig commented May 19, 2016
LGTM |
cjihrig commented May 19, 2016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits: Why the closure? If just for scope maybe use block scope. Also we prefer arrow functions (I guess)
{assert.throws(()=>{execSync('exit -1',{shell: 'no_shell'});},/spawnSyncno_shellENOENT/);}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar with Node.js code, so just copied the test from the end of this file and modified to thi particular use case.
But I can edit the comit and use your suggestion.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it's okay then. Don't bother.
Fishrock123May 19, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't even need the closure at all I think?
(Should probably be fixed before landing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a similar test further down below. This new test should probably be added there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...that and I guess everyone before just copy-pasted tests, which is why the closure has propagated :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is a similar test down below, but I put this test the first one, because it has to be ran before other calls to execSync.
For example, if the below test, with timeout, is ran before the one added in this patch, it could throw another exception, masking the real one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow your logic. If any test in this file fails the test runner marks it as failed. I don't see where exception masking comes in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the actual exception is masked, the one who runs the test won't be able to easily identify the problem.
If I move this test at the end, then there is no reason for adding it, since the first test will clearly fail.
The problem with accessing a null stderr is that the test with timeout will:
- fail in ETIMEOUT assert, this way err won't be assigned
- in it's finally clause, the assert for err.status will also throw another exception, since err is null
The test will fail telling that it cannot access the 'status' of an undefined member at "assert(err.status > 128 || err.signal)", which apparently appears to be a problem in the test itself.
eljefedelrodeodeljefe commented May 19, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
|
jasnell commented May 19, 2016
LGTM but agree that the test should be cleaned up a bit. |
robertchiras commented May 20, 2016
I cleaned the test as suggested. Should I also clean the similar test from the end of this test file in this patch too? |
bnoordhuis commented May 20, 2016
LGTM with a question: #6877 (comment)
No, that's fine. Let's see what the CI says: https://ci.nodejs.org/job/node-test-pull-request/2711/ |
bnoordhuis commented Jun 6, 2016
CI one more time: https://ci.nodejs.org/job/node-test-pull-request/2936/ |
lib/child_process.js Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test doesn't catch this one.
Fishrock123 commented Jun 15, 2016
LGTM minus the missing test. I will say error output when the test fails isn't the best, it could perhaps use a message parameter. |
Fishrock123 commented Jun 17, 2016
ping @robertchiras |
robertchiras commented Jun 21, 2016
@Fishrock123 sorry for my late response. I was gone, without access to a PC. |
Fishrock123 commented Jun 29, 2016
@robertchiras You also need a test for As for message, you may want to add a message argument as per the docs for |
Fishrock123 commented Jul 7, 2016
ping @robertchiras |
a6e6b6f to 2c1c798Comparerobertchiras commented Jul 11, 2016
@Fishrock123 sorry for the long delay. I updated the test according to your suggestions. |
If something bad happens in spawnSync, stderr might be null. Therefore, we have to check it before using it, so we won't mask the actual exception. Signed-off-by: Robert Chiras <[email protected]>
thefourtheye commented Jul 11, 2016
@robertchiras One last thing. The commits don't reflect your GitHub account. You might want to follow these steps https://help.github.com/articles/setting-your-username-in-git/ |
Fishrock123 commented Jul 11, 2016
Fishrock123 commented Jul 18, 2016
@robertchiras Mind updating your Git info for the commits? When you do I'll land this. :) $ git config --global user.email "[email protected]" $ git config --global user.name "J. Random User"Then $ git commit --amend --reset-author $ git push origin head --force |
robertchiras commented Jul 19, 2016
Hi @Fishrock123: I already had my git config set up. I did it again and pushed the changes. What do you see wrong in my commit that do not reflect my Github account? Thanks! |
Exercise the call to execSync with a bad shell passed through options. Verify that the right exception is thrown. Signed-off-by: Robert Chiras <[email protected]>
targos commented Jul 19, 2016
@robertchiras You need to add the email address you have setup in git to your GitHub profile: https://github.com/settings/emails |
robertchiras commented Jul 19, 2016
I used my work email address, probably this is why it didn't saw that it was me. I updated my work email account on Github. Now it should look good. |
If something bad happens in spawnSync, stderr might be null. Therefore, we have to check it before using it, so we won't mask the actual exception. PR-URL: #6877 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Robert Jefe Lindstädt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Fishrock123 commented Jul 19, 2016
Thanks! Landed in 765de1a 🎉 :D |
If something bad happens in spawnSync, stderr might be null. Therefore, we have to check it before using it, so we won't mask the actual exception. PR-URL: #6877 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Robert Jefe Lindstädt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
MylesBorins commented Sep 30, 2016
This change is causing tests to fail on v4.x-staging. Is this something we should be putting time into getting working on v4.x? |
robertchiras commented Oct 11, 2016
@thealphanerd, sorry for the late response. |
thefourtheye commented Oct 11, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@robertchiras This is the error I am getting |
MylesBorins commented Oct 11, 2016
@robertchiras the v4.x-staging branch is working fine for me without this fix applied. What OS are you on? |
robertchiras commented Oct 17, 2016
Sorry, but for some reason, I assumed that my patch is already in v4.x-staging. I applied it and saw the issue. |
If something bad happens in spawnSync, stderr might be null. Therefore, we have to check it before using it, so we won't mask the actual exception. PR-URL: nodejs#6877 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Robert Jefe Lindstädt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
If something bad happens in spawnSync, stderr might be null. Therefore, we have to check it before using it, so we won't mask the actual exception. Ref: #9152 PR-URL: #6877 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Robert Jefe Lindstädt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
If something bad happens in spawnSync, stderr might be null. Therefore, we have to check it before using it, so we won't mask the actual exception. Ref: #9152 PR-URL: #6877 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Robert Jefe Lindstädt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Checklist
Affected core subsystem(s)
child_process, test
Description of change
Fix for child_process when accessing a null stderr and addition test path to exercise this false path.