Skip to content

Strangeness in error message when node gives call stack, if error had occured in specially declared function #8322

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

Closed
nickkolok opened this issue Aug 29, 2016 · 7 comments
Labels
v8 engine Issues and PRs related to the V8 dependency.

Comments

@nickkolok
Copy link

nickkolok commented Aug 29, 2016

MWE:

nickolaus@nicknout:~/git/fraction.js$ js
> var obj = {};
undefined
> obj.a = obj.b = function(){throw err};
[Function]
> obj.b();
ReferenceError: err is not defined
    at Object.obj.a.obj.b (repl:1:34)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> obj.a();
ReferenceError: err is not defined
    at Object.obj.a.obj.b (repl:1:34)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> 

The strangeness is at Object.obj.a.obj.b (repl:1:34)

Pure MWE JS:

var obj = {};
obj.a = obj.b = function(){throw err};
obj.b();

Is it an error?

If the same object is declared in another way, everything is OK:

> var obj = {};
undefined
> obj.b = function(){throw err};
[Function]
> obj.a = obj.b;
[Function]
> obj.a();
ReferenceError: err is not defined
    at Object.obj.b (repl:1:26)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> obj.b();
ReferenceError: err is not defined
    at Object.obj.b (repl:1:26)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> 

@vkurchatkin vkurchatkin added the v8 engine Issues and PRs related to the V8 dependency. label Aug 29, 2016
@nickkolok
Copy link
Author

A bit fuller example:

> var obj = {};
undefined
> obj.b = function(){throw err};
[Function]
> obj.a = obj.b;
[Function]
> obj.a();
ReferenceError: err is not defined
    at Object.obj.b (repl:1:26)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> obj.b();
ReferenceError: err is not defined
    at Object.obj.b (repl:1:26)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> obj.c = obj.d = obj.a;
[Function]
> obj.c();
ReferenceError: err is not defined
    at Object.obj.b (repl:1:26)
    at repl:1:5
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> 

@nickkolok
Copy link
Author

@vkurchatkin, should I report this to V8 now?

@evanlucas
Copy link
Contributor

@nickkolok can you try with the v6.5.0 and see if you can reproduce? v5.x hit end of life a few months ago.

@princejwesley
Copy link
Contributor

Tested against chrome 52.0.2743.116 (64-bit) & 55.0.2843.0 canary (64-bit).
image
Only difference is, there is no Object. prefix in chrome console.

@nickkolok
Copy link
Author

@evanlucas I'd be be glad if you helped me to install it on Ubuntu 12.04.

@Slayer95
Copy link

Slayer95 commented Aug 29, 2016

I've seen all sorts of weird stack traces before.
Glad to see that someone has found a reduced test case for at least a subset of them!

@bnoordhuis
Copy link
Member

This is a V8 issue, not something we have direct control over. Can you report it here: https://bugs.chromium.org/p/v8/issues/list? Thanks.

FWIW, the output doesn't seem unreasonable to me given the constraints. The function has no name so V8 tries to infer one from context. If you write it like obj.a = obj.b = function f(){throw err}, you get Object.f in the stack trace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

6 participants