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
lib: fix issue throw null and throw undefined and also throw false crash in repl#16574
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
priyank-p commented Oct 28, 2017 • 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.
priyank-p commented Oct 28, 2017
# output make[1]: Leaving directory `/home/ubuntu/workspace/node'/usr/bin/python2.7 tools/test.py --mode=release -J \ async-hooks \ default \ addons addons-napi \ doctool known_issues=== release test-stringbytes-external-exceed-max === Path: addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-maxCommand: out/Release/node /home/ubuntu/workspace/node/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js--- CRASHED (Signal: 9) ---=== release test-stringbytes-external-exceed-max-by-1-binary === Path: addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binaryCommand: out/Release/node /home/ubuntu/workspace/node/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js--- CRASHED (Signal: 9) ---=== release test-stringbytes-external-exceed-max-by-1-hex === Path: addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hexCommand: out/Release/node /home/ubuntu/workspace/node/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js--- CRASHED (Signal: 9) ---=== release test-timers-block-eventloop === Path: sequential/test-timers-block-eventloopassert.js:45 throw new errors.AssertionError({ ^AssertionError [ERR_ASSERTION]: eventloop blocked! at Timeout.mustNotCall [as _onTimeout] (/home/ubuntu/workspace/node/test/common/index.js:582:12) at ontimeout (timers.js:478:11) at tryOnTimeout (timers.js:302:5) at Timer.listOnTimeout (timers.js:262:5)Command: out/Release/node /home/ubuntu/workspace/node/test/sequential/test-timers-block-eventloop.js[12:02|% 100|+ 2038|- 4]: Done make: *** [test] Error 1 |
mscdex commented Oct 28, 2017
The target subsystem should be 'repl' instead of 'lib' in the commit message. |
lib/repl.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.
You can merge this with line 266-269 if you change the condition on line 260 to err && err.message === ... and line 275 to just if (process.domain){.
Can you also add a regression test? 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.
test/parallel/test-repl-domain.js is probably the right place for it, although if you can fit it in one of the other test/parallel/test-repl-* tests, that's probably perfectly alright too.
priyank-pOct 28, 2017 • 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.
@bnoordhuis added regression test and fixed changes requested.
The issue was that when it tries to check if `err.message == 'Script execution interrupted.'` line 269 repl.js it throws error as e would be `null` or `undefined`. Now before it checks the err.message it checks if err was `null|undefined` and id so returns err before checking and exits, ` // sample output repl > throw null Thrown null > throw undefined Thrown undefined ` Fixes: #16545
joyeecheung commented Oct 29, 2017
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.
makes sures -> makes sure
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.
IMO new tests can accommodate arrow functions whenever possible.
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.
While this mostly works, the eventemitter manifests pure asynchronous behavior and does not guarentee any order of listener invocation with respect to the order of the associated event, at least by specification. Is it possible to see if replOutput function can handle both the possibilities?
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.
How about replacing this with template strings?
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.
same as above
priyank-p commented Oct 29, 2017
@gireeshpunathil fixed all the changes requested. Also fixed issue that not all the time the asserstion would be made as All changes are amended to previous nit commit. |
gireeshpunathil left a comment
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.
great, thank you!
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.
Nit: can you please remove the trailing space? There is already one in the template string below.
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.
Nit: can you please use assert.strictEqual()?
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.
Ditto.
priyank-p commented Oct 30, 2017
@lpinca i added replaced the existing test as it does not throw error on previous node version |
throw null and throw undefined crash in replthrow null and throw undefined and also throw false crash in replpriyank-p commented Oct 30, 2017
There is no way to test |
lance left a comment
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.
CI looks good except for flakey raspberry pi builds
Fishrock123 left a comment
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.
lance commented Oct 31, 2017
Landed in bb59d2b |
When `throw undefined` or `throw null` is executed, the REPL crashes. This change does a check for `null|undefined` before accessing an error's properties to prevent crashing. Fixes: #16545Fixes: #16607 PR-URL: #16574 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Lance Ball <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
When `throw undefined` or `throw null` is executed, the REPL crashes. This change does a check for `null|undefined` before accessing an error's properties to prevent crashing. Fixes: nodejs/node#16545Fixes: nodejs/node#16607 PR-URL: nodejs/node#16574 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Lance Ball <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
When `throw undefined` or `throw null` is executed, the REPL crashes. This change does a check for `null|undefined` before accessing an error's properties to prevent crashing. Fixes: nodejs/node#16545Fixes: nodejs/node#16607 PR-URL: nodejs/node#16574 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Lance Ball <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
When `throw undefined` or `throw null` is executed, the REPL crashes. This change does a check for `null|undefined` before accessing an error's properties to prevent crashing. Fixes: nodejs#16545Fixes: nodejs#16607 PR-URL: nodejs#16574 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Lance Ball <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
MylesBorins commented Nov 14, 2017
This fix does not appear to fix the problem on v6.x Would someone be willing to do a manual backport? |
When `throw undefined` or `throw null` is executed, the REPL crashes. This change does a check for `null|undefined` before accessing an error's properties to prevent crashing. Fixes: #16545Fixes: #16607 PR-URL: #16574 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Lance Ball <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
When `throw undefined` or `throw null` is executed, the REPL crashes. This change does a check for `null|undefined` before accessing an error's properties to prevent crashing. Fixes: nodejs/node#16545Fixes: nodejs/node#16607 PR-URL: nodejs/node#16574 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Lance Ball <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
The issue was that when it tries to check if
err.message == 'Script execution interrupted.'line 269 repl.js it throws error as e would be
nullorundefined. Now before it checksthe err.message it checks if err was
null|undefinedand id so returns err before checkingand exits,
Fixes: #16545
Fixes: #16607
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesFor make -j4 test
make error 1 Flaky test-timers-block-eventloopFlaky test-timers-block-eventloop #16310commit message follows commit guidelines
Affected core subsystem(s)
repl