Get "Fatal error in HandleScope::HandleScope" when running compiled JS with execeptions.

1,267 views
Skip to first unread message

Then

unread,
Apr 29, 2013, 7:02:30 AM4/29/13
to v8-u...@googlegroups.com
Hi,

I use V8 under Visual Studio 2010 on Windows 7.

I have following problem. I try to run several Java Scripts, each in a separate thread. For each thread I use a separate isolate.
This works fine if the script works well, so it does not produce any exceptions.

But if an exception occurs (e.g. caused by a syntax error), following ASSERT is thrown:
#
# Fatal error in HandleScope::HandleScope
# Entering the V8 API without proper locking in place
#

This is the callstack:

  V8Test.exe!v8::internal::OS::DebugBreak() Line 1009 C++
  V8Test.exe!v8::internal::OS::Abort() Line 1000 C++
  V8Test.exe!API_Fatal(const char * location, const char * format, ...) Line 101 C++
  V8Test.exe!v8::DefaultFatalErrorHandler(const char * location, const char * message) Line 134 C++
  V8Test.exe!v8::Utils::ReportApiFailure(const char * location, const char * message) Line 226 C++
  V8Test.exe!v8::ApiCheck(bool condition, const char * location, const char * message) Line 240 C++
  V8Test.exe!v8::HandleScope::Initialize(v8::Isolate * isolate) Line 667 C++
  V8Test.exe!v8::HandleScope::HandleScope(v8::Isolate * isolate) Line 662 C++
> V8Test.exe!v8::internal::Factory::NewError(const char * maker, const char * type, v8::internal::Vector<v8::internal::Handle<v8::internal::Object> > args) Line 720 C++
  V8Test.exe!v8::internal::Factory::NewReferenceError(const char * type, v8::internal::Vector<v8::internal::Handle<v8::internal::Object> > args) Line 706 C++
  V8Test.exe!v8::internal::IC::ReferenceError(const char * type, v8::internal::Handle<v8::internal::String> name) Line 286 C++
  V8Test.exe!v8::internal::LoadIC::Load(v8::internal::InlineCacheState state, v8::internal::Handle<v8::internal::Object> object, v8::internal::Handle<v8::internal::String> name) Line 901 C++
  V8Test.exe!v8::internal::LoadIC_Miss(v8::internal::Arguments args, v8::internal::Isolate * isolate) Line 2090 C++
....

The Problem can be avoided if I lock the whole script execution, but that would be no practicable solution for me.
Is there another way to solve this problem? Or is this a V8 bug?

Any help would be appreciated. Thanks!

Sven Panne

unread,
Apr 29, 2013, 7:26:35 AM4/29/13
to v8-u...@googlegroups.com
If you use v8::Locker anywhere, you have to use it everywhere. If you that's not practicable for you, you'll have to ensure that at most one thread is executing within each given Isolate by other means, i.e. locking on your application side.

Then

unread,
Apr 29, 2013, 8:01:40 AM4/29/13
to v8-u...@googlegroups.com
Hi, thank you for your fast answer.

I know that I have to use v8:Locker, and I use it at any place I am able to. 
But my problem is that v8-code itself uses "HandleScope::HandleScope" - this call is responsible for the ASSERT. And this code passage is NOT being locked.
It occurs during v8::Script::Run, namely when the script throws an exception (please see the call stack in the email before).

Is it possible for me to avoid this situation without locking the execution of "v8::Script::Run"? 
Locking "Run" would mean to serialize the execution of all JavaScripts ( which would be very slow :( )

Or is the problem possibly a problem/bug of v8?

Thank you again!

Dmitry Lomov

unread,
Apr 29, 2013, 8:15:46 AM4/29/13
to v8-u...@googlegroups.com
v8::Script::Run should be protected by a locker. V8 generally cannot execute scripts operating on the same heap in parallel.
If you want to execute scripts in parallel, take a look at v8::Isolate class and related comments.


--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Then

unread,
Apr 30, 2013, 4:28:45 AM4/30/13
to v8-u...@googlegroups.com
Hi, thanks for the response.

I am not 100% sure if I understand you correctly. Do you mean that if I used one isolate for each thread, it should work?
- I am currently using exactly one isolate for each thread. 
- One script is compiled and executed in exactly one thread. 
- And I am not sharing anything between the scripts - they run fully independently.
And my test application runs successfully if the scripts do not produce any error.

But if at least one script produces a runtime error, the program stops with the fatal error message described above.
By the way, I get the fatal error also if I start only one of the threads (if the script is erroneous).
Reply all
Reply to author
Forward
0 new messages