code-google-com / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

Error/Crash using multiple JSContext in multiple threads #42

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
(http://groups.google.com/group/pyv8/browse_thread/thread/78df210cac5cfbc3)

I'm having some problems running different JSContext instances in
different threads. This is a simplified example:

--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--
from __future__ import with_statement
from pyv8 import PyV8
from threading import Thread

class PyV8Tread(Thread):
    def run(self):
        with PyV8.JSContext() as context:
            context.eval("1+1")

t1 = PyV8Tread()
t2 = PyV8Tread()
t3 = PyV8Tread()
t1.start()
t2.start()
t3.start()
--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--

When I run those lines, I randomly get:
a) "#
# Fatal error in ..\..\src\top.cc, line 283
# CHECK(thread_local_.TryCatchHandler() == that) failed
#"

b) Python crashes

With this modification:
--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--
class PyV8Tread(Thread):
    def run(self):
        class Global(PyV8.JSClass):
            def hello(self):
                print "Hello World"

        with PyV8.JSContext(Global()) as context:
            context.eval("hello()")
--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--
I get:
"#
# Fatal error in ..\..\src\frames.cc, line 46
# CHECK(frame->sp() <= handler->address()) failed
#

Attempt to print stack while printing stack (double fault)
If you are lucky you may find a partial stack dump on stdout.

==== Stack trace ============================================"

Python 2.5
Boost 1.42
V8 trunk, revision 4135 

Original issue reported on code.google.com by mmura...@dieresys.com.ar on 18 Mar 2010 at 7:23

GoogleCodeExporter commented 9 years ago

Original comment by flier...@gmail.com on 19 Mar 2010 at 2:27

GoogleCodeExporter commented 9 years ago
I am still able to reproduce this defect. What is its status?

Original comment by PremyslK...@gmail.com on 13 Aug 2010 at 12:04

GoogleCodeExporter commented 9 years ago
Can't reproduce it with the latest SVN trunk code, but we must enter a isolate 
before use it in a separate thread

from __future__ import with_statement
import PyV8
from threading import Thread

class PyV8Tread(Thread):
    def run(self):
        with PyV8.JSIsolate():
            with PyV8.JSContext() as context:
                context.eval("1+1")

                del context

t1 = PyV8Tread()
t2 = PyV8Tread()
t3 = PyV8Tread()
t1.start()
t2.start()
t3.start()

Original comment by flier...@gmail.com on 15 Jul 2011 at 4:37