New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 5 users

Issue metadata

Status: Duplicate
Merged: issue chromium:60240
Owner:
Email to this user bounced
Closed: Mar 2013
HW: ----
NextAction: ----
OS: ----
Priority: ----
Type: ----



Sign in to add a comment

Incorrect stack trace.

Reported by coldredl...@gmail.com, Jun 30 2010

Issue description

This script does not seem to produce the correct output:

  function f() {
    JSON.parse(undefined);
  }

  function g() {
    try {
      f();
    } catch (err) {
      throw err;
    }
  }

  g();


You would expect f() to show up in the stacktrace. Firefox reports: 

  f()@http://getfirebug.com/:72 g()@http://getfirebug.com/:73
  ("with(_FirebugCommandLine){g();\n};")@http://getfirebug.com/:71
  ("with(_FirebugCommandLine){g();\n};")@http://getfirebug.com/:71 _firebugEvalEvent([object Event])@http://getfirebug.com/:60 
 
Status: Assigned
Currently JSON.parse(undefined) throws the string "illegal access" because of the argument check at http://code.google.com/p/v8/source/browse/trunk/src/runtime.cc#7395.  The spec says that the 'text' argument should be converted to a string before parsing (15.12.2 step 1, p. 202) so that is incorrect.  We should do the conversion and then, in this case, throw a proper SyntaxError.  Note that if you do JSON.parse("undefined") you get:

SyntaxError: Unexpected token ILLEGAL
    at Object.parse (native)
    at f (<...>)
    at g (<...>)
    at <...>

which is slightly incorrect -- the top frame should be JSON.parse, not Object.parse.  We can fix that by clearing the JSON.constructor property when creating the JSON object.

Assigning to Mads (as suggested by Erik).

Comment 2 by ager@chromium.org, Jul 13 2010

Thanks Christian! I'm fixing the string conversion problem first (which is caused by a simple typo). It seems that the slightly incorrect formatting goes a little deeper. The problem is that JSON.__proto__ === Object.prototype and therefore the constructor property is the Object function.

We do have a class name set to "JSON" so we could probably use that to fix the printing issue.

Comment 3 by ager@chromium.org, Jul 13 2010

Conversion problem fixed in r5051.

Comment 4 by get...@gmail.com, Feb 1 2011

I'm seeing this behavior even for a ReferenceError, in that if I re-throw the caught error object, it loses the original source context for the error and overrides it with where the error was thrown.

This gist illustrates:

https://gist.github.com/802625
Mergedinto: chromium:60240
Status: Duplicate
The stack trace issue for rethrown Error objects has long been solved.

Sign in to add a comment