Status: New
Owner: ----

New issue 2112 by [email protected]: Stacktraces originating from `JSON.parse()` contain random garbage (on nodejs)
http://code.google.com/p/v8/issues/detail?id=2112

This script

setTimeout(function(res) {
  JSON.parse('{x:1}');
}, 0);

produces this output on node 0.6.15 (v8 version 3.6.4), Linux 32 Bit (3.2.0-24-generic). The garbage is different on every run.

$ node stacktrace-garbage.js

undefined:1
,!M�-!I�,!m�-!��'�'eT-!��,!�S-!9�'Y�,!��'-�,!�-!m�c_
^
SyntaxError: Unexpected token x
    at Object.parse (native)
at Timer._callback (/home/jonas/dev/mbr/stacktrace-garbage/stacktrace-garbage.js:2:8)
    at Timer.<anonymous> (timers.js:172:14)

cat stacktrace-garbage.js
setTimeout(function(res) {
  JSON.parse('{x:1}');
}, 0);

On node 0.7.8 (v8 version 3.9.24) this trivial case works well, but JSON.stringify() called from http still produces outputs undefined:1 but without garbage. This is probably v8's fault. The attached naive patch fixes to problem.


Attachments:
        0001-Naive-fix-for-garbage-output.patch  843 bytes

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to