terratenney / pyv8

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

Segmentation Fault using JSON #125

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

import PyV8
import ujson

a = ujson.encode([1,2,3])

code = """
c = JSON.parse('%s');
c;
""" % a
print code
ctxt = PyV8.JSContext(a)
ctxt.enter()
response = ctxt.eval(code)
ctxt.leave()
print response

Original issue reported on code.google.com by flier...@gmail.com on 11 Jun 2012 at 8:20

GoogleCodeExporter commented 9 years ago
Process:         Python [77262]
Path:            
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app
/Contents/MacOS/Python
Identifier:      Python
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  bash [437]

Date/Time:       2012-06-11 16:18:41.254 +0800
OS Version:      Mac OS X 10.7.4 (11E53)
Report Version:  9

Interval Since Last Report:          115164 sec
Crashes Since Last Report:           1
Per-App Crashes Since Last Report:   1
Anonymous UUID:                      9AA2C26E-E14D-43C0-8F46-DAF8F8547CAB

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000027

VM Regions Near 0x27:
--> 
    __TEXT                 0000000103601000-0000000103602000 [    4K] r-x/rwx SM=COW  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

Application Specific Information:
objc[77262]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   _PyV8.so                        0x0000000103e0c734 
v8::internal::Context::builtins() + 0
1   _PyV8.so                        0x0000000103e3160c 
v8::internal::Execution::ToString(v8::internal::Handle<v8::internal::Object>, 
bool*) + 58
2   _PyV8.so                        0x0000000103dea00b v8::Value::ToString() 
const + 279
3   _PyV8.so                        0x0000000103d6222c 
CJavascriptObject::Dump(std::ostream&) const + 428 (v8.h:207)
4   _PyV8.so                        0x0000000103d75729 bool 
boost::detail::lexical_stream_limited_src<char, std::char_traits<char>, 
true>::shl_input_streamable<CJavascriptObject const>(CJavascriptObject const&) 
+ 169 (lexical_cast.hpp:1260)
5   _PyV8.so                        0x0000000103d75514 
boost::detail::lexical_cast_do_cast<std::string, 
CJavascriptObject>::lexical_cast_impl(CJavascriptObject const&) + 180 
(lexical_cast.hpp:1920)
6   _PyV8.so                        0x0000000103d753d8 
boost::python::detail::operator_1<(boost::python::detail::operator_id)19>::apply
<CJavascriptObject>::execute(CJavascriptObject&) + 24 (basic_string.h:279)
7   _PyV8.so                        0x0000000103d75953 
boost::python::objects::caller_py_function_impl<boost::python::detail::caller<_o
bject* (*)(CJavascriptObject&), boost::python::default_call_policies, 
boost::mpl::vector2<_object*, CJavascriptObject&> > >::operator()(_object*, 
_object*) + 51 (builtin_converters.hpp:171)
8   libboost_python-mt.dylib        0x00000001046c2363 
boost::python::objects::function::call(_object*, _object*) const + 733
9   libboost_python-mt.dylib        0x00000001046c0f10 
boost::detail::function::void_function_ref_invoker0<boost::python::objects::(ano
nymous namespace)::bind_return, 
void>::invoke(boost::detail::function::function_buffer&) + 32
10  libboost_python-mt.dylib        0x00000001046ca08c 
boost::python::detail::exception_handler::operator()(boost::function0<void> 
const&) const + 174
11  _PyV8.so                        0x0000000103d3f466 
boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<bool, 
boost::python::detail::translate_exception<CJavascriptException, void 
(*)(CJavascriptException const&)>, boost::_bi::list3<boost::arg<1>, 
boost::arg<2>, boost::_bi::value<void (*)(CJavascriptException const&)> > >, 
bool, boost::python::detail::exception_handler const&, boost::function0<void> 
const&>::invoke(boost::detail::function::function_buffer&, 
boost::python::detail::exception_handler const&, boost::function0<void> const&) 
+ 22 (function_template.hpp:132)
12  libboost_python-mt.dylib        0x00000001046ca0f3 
boost::python::handle_exception_impl(boost::function0<void>) + 99
13  libboost_python-mt.dylib        0x00000001046c143f function_call + 79
14  org.python.python               0x0000000103615921 PyObject_Call + 97
15  org.python.python               0x0000000103621876 instancemethod_call + 518
16  org.python.python               0x0000000103615921 PyObject_Call + 97
17  org.python.python               0x00000001036ae901 
PyEval_CallObjectWithKeywords + 177
18  org.python.python               0x000000010366fd88 slot_tp_str + 168
19  org.python.python               0x000000010365323f _PyObject_Str + 127
20  org.python.python               0x0000000103652eea internal_print + 218
21  org.python.python               0x0000000103630eca PyFile_WriteObject + 234
22  org.python.python               0x00000001036a960f PyEval_EvalFrameEx + 6255
23  org.python.python               0x00000001036a7d4f PyEval_EvalCodeEx + 2079
24  org.python.python               0x00000001036a7526 PyEval_EvalCode + 54
25  org.python.python               0x00000001036cef7e PyRun_FileExFlags + 174
26  org.python.python               0x00000001036ce95a PyRun_SimpleFileExFlags + 
410
27  org.python.python               0x00000001036e2a82 Py_Main + 2914
28  org.python.python               0x0000000103601f24 0x103601000 + 3876

Thread 1:: SamplerThread
0   libsystem_kernel.dylib          0x00007fff85e56e42 __semwait_signal + 10
1   libsystem_c.dylib               0x00007fff8eaffdea nanosleep + 164
2   libsystem_c.dylib               0x00007fff8eaffbb5 usleep + 53
3   _PyV8.so                        0x0000000103f46615 
v8::internal::SamplerThread::Run() + 131
4   _PyV8.so                        0x0000000103f459ad 
_ZN2v88internalL11ThreadEntryEPv + 61
5   libsystem_c.dylib               0x00007fff8eb498bf _pthread_start + 335
6   libsystem_c.dylib               0x00007fff8eb4cb75 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007fff631ffc57  rcx: 0x0000000000000102  rdx: 0x000025d110105409
  rdi: 0x0000000000000000  rsi: 0x00007fff631ffc57  rbp: 0x00007fff631ffce0  rsp: 0x00007fff631ffc08
   r8: 0x00007fff631ffc3c   r9: 0x00007fff631ffc38  r10: 0x0000000000000081  r11: 0x00007fff738c2df9
  r12: 0x00000001046c13f0  r13: 0x00007fca5b49dbd0  r14: 0x00007fca5b8a4600  r15: 0x0000000000000004
  rip: 0x0000000103e0c734  rfl: 0x0000000000010202  cr2: 0x0000000000000027
Logical CPU: 2

Original comment by flier...@gmail.com on 11 Jun 2012 at 8:24

GoogleCodeExporter commented 9 years ago
It caused by using JS object out of context, just raise a UnboundLocalError 
exception.

Original comment by flier...@gmail.com on 11 Jun 2012 at 3:02

GoogleCodeExporter commented 9 years ago
Please check out the SVN trunk code after r441 to verify the issue

Original comment by flier...@gmail.com on 11 Jun 2012 at 3:04

GoogleCodeExporter commented 9 years ago

Original comment by flier...@gmail.com on 12 Jun 2012 at 2:31