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

throw null and throw undefined crash in repl #16545

Closed
IonicaBizau opened this issue Oct 27, 2017 · 4 comments
Closed

throw null and throw undefined crash in repl #16545

IonicaBizau opened this issue Oct 27, 2017 · 4 comments
Labels
repl Issues and PRs related to the REPL subsystem.

Comments

@IonicaBizau
Copy link
Contributor

  • Version: 8.6.0
  • Platform: macOS
  • Subsystem: High Sierra

While setTimeout(function(){throw null},0) doesn't crash anymore (as reported in #12373 and fixed in #14306), throw null (also throw undefined) seem to crash the toplevel.

I'd be happy to contribute if you give me a bit of guidance. 😄

$ node --version
v8.6.0
$ node
> throw null
TypeError: Cannot read property 'message' of null
    at REPLServer.defaultEval (repl.js:257:16)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:440:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
    at REPLServer.Interface._line (readline.js:631:8)
    at REPLServer.Interface._ttyWrite (readline.js:911:14)
    at REPLServer.self._ttyWrite (repl.js:509:7)
> setTimeout(function() { throw null }, 0)
Timeout {
  _called: false,
  _idleTimeout: 1,
  _idlePrev: 
   TimersList {
     _idleNext: [Circular],
     _idlePrev: [Circular],
     _timer: Timer { '0': [Function: listOnTimeout], _list: [Circular] },
     _unrefed: false,
     msecs: 1,
     nextTick: false },
  _idleNext: 
   TimersList {
     _idleNext: [Circular],
     _idlePrev: [Circular],
     _timer: Timer { '0': [Function: listOnTimeout], _list: [Circular] },
     _unrefed: false,
     msecs: 1,
     nextTick: false },
  _idleStart: 8459,
  _onTimeout: [Function],
  _timerArgs: undefined,
  _repeat: null,
  _destroyed: false,
  domain: 
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] },
  [Symbol(asyncId)]: 118,
  [Symbol(triggerAsyncId)]: 5 }
> Thrown: null
@mscdex mscdex added the repl Issues and PRs related to the REPL subsystem. label Oct 27, 2017
@bnoordhuis
Copy link
Member

@IonicaBizau Look for a try/catch block around that line in lib/repl.js (I mean the first line of the stack trace) and please add one or two regression tests in test/parallel/test-repl.js. Don't hesitate to ask if you have questions.

@IonicaBizau
Copy link
Contributor Author

@bnoordhuis Thank you very much! Will work on it these days.

@priyank-p
Copy link
Contributor

@IonicaBizau i already got it fixed. Need to make a pull request after making test and linting

@IonicaBizau
Copy link
Contributor Author

@cPhost Ah, cool! 👍 Thanks!

@lance lance closed this as completed in bb59d2b Oct 31, 2017
Qard pushed a commit to ayojs/ayo that referenced this issue Nov 2, 2017
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#16545
Fixes: nodejs/node#16607

PR-URL: nodejs/node#16574
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Qard pushed a commit to ayojs/ayo that referenced this issue Nov 2, 2017
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#16545
Fixes: nodejs/node#16607

PR-URL: nodejs/node#16574
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
cjihrig pushed a commit to cjihrig/node that referenced this issue Nov 6, 2017
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#16545
Fixes: nodejs#16607

PR-URL: nodejs#16574
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
gibfahn pushed a commit that referenced this issue Nov 14, 2017
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: #16545
Fixes: #16607

PR-URL: #16574
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
addaleax pushed a commit to ayojs/ayo that referenced this issue Dec 7, 2017
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#16545
Fixes: nodejs/node#16607

PR-URL: nodejs/node#16574
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants