RoamUniverse / pyv8

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

Segmentation fault #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
On Ubuntu 8.04
1a. Use svn checkout http://v8.googlecode.com/svn/trunk/ v8
 or
1b. Use svn checkout http://v8.googlecode.com/svn/branches/bleeding_edge/ v8
2. Use svn checkout http://pyv8.googlecode.com/svn/trunk/ pyv8-read-only
3. apt-get install install libboost-python-dev
4. apt-get install scons
5. Compile v8 with 'scons' (no arguments)
6. Copy v8-debug.h, v8.h and libv8.a to the lib/v8/*/
7. python setup.py build
8. cd build/lib.linux-i686-2.5/
9. python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyV8
>>> e = PyV8.JSEngine(object())
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
   JSEngine.__init__(JSEngine, object)
did not match C++ signature:
   __init__(_object*)
>>> e = PyV8.JSEngine()
>>> e.eval()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
AttributeError: 'JSEngine' object has no attribute 'eval'
>>> e.compile()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
   JSEngine.compile(JSEngine)
did not match C++ signature:
   compile(CEngine {lvalue}, std::string source, std::string name='',
int line=-1, int col=-1)
>>> e.compile('a=1')
Segmentation fault

What is the expected output? What do you see instead?
Anything but 'Segmentation fault'

What version of the product are you using? On what operating system?
svn versions on Ubuntu 8.04

Please provide any additional information below.

The PyV8.JSEngine().eval() is not available which is used in the pyjamas
pyv8/pyv8run.py example.

Original issue reported on code.google.com by cornelis...@gmail.com on 20 Jun 2009 at 12:39

GoogleCodeExporter commented 9 years ago
The issue was caused by a wrong assumption, because the compile and eval 
method of JSEngine need a entered context; so, if you directly call those 
methods, 
it will crash in release mode and hit a assert in debug mode.

http://code.google.com/p/pyv8/source/detail?r=125

Now, I change the code to throw a exception instead of 'Segmentation fault'

Please ensure you have enter a context before use the JSEngine, or directly use 
JSContext as delegate

>>> import PyV8
>>> ctxt = PyV8.JSContext()          # create a context with an implicit global 
object
>>> ctxt.enter()                     # enter the context (also support with 
statement)

Original comment by flier...@gmail.com on 20 Jun 2009 at 3:44