code-google-com / pyv8

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

"Bus error" when invoking PyV8 not from python main thread on MacOs. #92

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Script in the attached test_pyv8_main_thread.py works fine - computes JS 
"1+2" and prints 3.
2. The same code run from separate python thread from the attached 
test_pyv8_separate_thread.py crached with "Bus error"

What is the expected output? What do you see instead?
I expected the same result as the code run from the main python thread - "3" 
printed on console.

What version of the product are you using? On what operating system?
MacOs 10.6.7 64-bit
Python 2.5.4 32-bin
boost 1.46.1 manually compiled using
./bjam threading=multi link=static toolset=darwin architecture=x86 
address-model=32 install --with-python --layout=tagged --build-type=complete
V8 3.4.4
PyV8 from trunk (svn r381)

Please provide any additional information below.

Original issue reported on code.google.com by viy....@gmail.com on 28 Jun 2011 at 2:27

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by flier...@gmail.com on 28 Jun 2011 at 5:04

GoogleCodeExporter commented 9 years ago
Also crashed but with "Segmentation fault" in env:
MacOs 10.6.7 64-bit
Python *2.6.5 64-bit*
boost 1.46.1 manually compiled using
./bjam threading=multi link=static toolset=darwin architecture=x86 
address-model=*64* install --with-python --layout=tagged --build-type=complete
V8 3.4.4
PyV8 from trunk (svn r381)

Original comment by viy....@gmail.com on 30 Jun 2011 at 8:27

GoogleCodeExporter commented 9 years ago
It seems V8 has changed its multi-threading strategy, we must enter a new 
isolate before run script in a separate thread, please use PyIsolate with PyV8 
SVN trunk code after r386. Thanks

import threading

import PyV8

def test(js_str, *args):
    ctxt = PyV8.JSContext()
    ctxt.enter()
    return ctxt.eval(js_str % args)

def run_pyv8():
    with PyV8.JSIsolate():
        print test("1+2")

th = threading.Thread(target=run_pyv8, name="separate_thread")
th.start()

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