Javascript call stack exceeded on call to JSON.parse

313 views
Skip to first unread message

Sridatta

unread,
Apr 25, 2011, 10:29:01 PM4/25/11
to v8-users
I'm trying to call the native JSON parser from my v8 extension.
However, when I do this, I get the following error: "Uncaught
RangeError: Maximum call stack size exceeded". My code can be found
here: https://gist.github.com/941668 . Can someone suggest what I'm
doing wrong?

Lasse R.H. Nielsen

unread,
Apr 26, 2011, 1:09:48 AM4/26/11
to v8-u...@googlegroups.com
The obvious guess is that the JSON parser, which is recursive, actually exhausts the stack while parsing.
Do you have a link to the module being parsed?

/L




--
Lasse R.H. Nielsen
l...@google.com
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K -
Denmark - CVR nr. 28 86 69 84

Erik Corry

unread,
Apr 26, 2011, 2:44:45 AM4/26/11
to v8-u...@googlegroups.com
Den 26. apr. 2011 07.09 skrev Lasse R.H. Nielsen <l...@chromium.org>:
The obvious guess is that the JSON parser, which is recursive, actually exhausts the stack while parsing.
Do you have a link to the module being parsed?

It could also be a bug in using V8 with multiple threads.
 

/L


On Tue, Apr 26, 2011 at 04:29, Sridatta <sthati...@gmail.com> wrote:
I'm trying to call the native JSON parser from my v8 extension.
However, when I do this, I get the following error: "Uncaught
RangeError: Maximum call stack size exceeded". My code can be found
here: https://gist.github.com/941668 . Can someone suggest what I'm
doing wrong?

--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users



--
Lasse R.H. Nielsen
l...@google.com
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K -
Denmark - CVR nr. 28 86 69 84



--
Erik Corry, Software Engineer
Google Denmark ApS - Frederiksborggade 20B, 1 sal,

Sridatta Thatipamala

unread,
Apr 26, 2011, 2:58:43 AM4/26/11
to v8-u...@googlegroups.com
I am indeed trying to use V8 from a background thread. Here is a
little more code for context: https://gist.github.com/941913 . (Not
actual code. I simplified it for context).
I want to have a background thread be able to call and access the V8
instance. Is it possible?

Erik Corry

unread,
Apr 27, 2011, 3:26:44 AM4/27/11
to v8-u...@googlegroups.com
Den 26. apr. 2011 08.58 skrev Sridatta Thatipamala <sthati...@gmail.com>:
I am indeed trying to use V8 from a background thread. Here is a
little more code for context: https://gist.github.com/941913 . (Not
actual code. I simplified it for context).
I want to have a background thread be able to call and access the V8
instance. Is it possible?

Yes.  You have to use the v8::Locker class in both the main thread and the background thread.  It's a class that does its work in the constructor and the destructor.  See include/v8.h for a description of its use.

Stephan Beal

unread,
Apr 27, 2011, 10:38:21 AM4/27/11
to v8-u...@googlegroups.com
On Wed, Apr 27, 2011 at 9:26 AM, Erik Corry <erik....@gmail.com> wrote:
Yes.  You have to use the v8::Locker class in both the main thread and the background thread.  It's a class that does its work in the constructor and the destructor.  See include/v8.h for a description of its use.

And when you use it BE SURE to add a Locker instance in your main() BEFORE doing anything with v8 except perhaps calling v8::V8::SetFlagsFromCommandLine(). If you just add it to your callbacks they will crash (in debug mode it tells you you've mis-used the locker, but in non-debug mode it just crashes).

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
Reply all
Reply to author
Forward
0 new messages