fpx406 / pyv8

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

Segmentation fault #217

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
After updating to -r560 I experienced this issue

buffer@rigel ~/pyv8 $ python PyV8.py
Segmentation fault

buffer@rigel ~/pyv8 $ gdb python
(gdb) r PyV8.py
Starting program: /usr/bin/python PyV8.py
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
process 415 is executing new program: /usr/bin/python2.7
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff3170700 (LWP 459)]
[New Thread 0x7ffff7ff9700 (LWP 460)]
[New Thread 0x7ffff7fe8700 (LWP 461)]
[New Thread 0x7ffff7fd7700 (LWP 462)]
[New Thread 0x7ffff6b52700 (LWP 463)]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff749eaf4 in vfprintf () from /lib64/libc.so.6
(gdb) info stack
#0  0x00007ffff749eaf4 in vfprintf () from /lib64/libc.so.6
#1  0x00007ffff7550a89 in __vsnprintf_chk () from /lib64/libc.so.6
#2  0x00007ffff4899dd5 in 
v8::internal::OS::VSNPrintF(v8::internal::Vector<char>, char const*, 
__va_list_tag*) () from 
/home/buffer/.python-eggs/PyV8-1.0_dev-py2.7-linux-x86_64.egg-tmp/_PyV8.so
#3  0x00007ffff455160f in v8::internal::PrettyPrinter::Print 
(this=this@entry=0x7fffffffa530, format=format@entry=0x7ffff48da601 "\"%s\"") 
at src/PrettyPrinter.cpp:514
#4  0x00007ffff455689a in v8::internal::JsonAstBuilder::AddAttribute 
(this=this@entry=0x7fffffffa530, name=name@entry=0x7ffff48df7e1 "name", 
value=...) at src/PrettyPrinter.cpp:1231
#5  0x00007ffff45576f4 in v8::internal::JsonAstBuilder::VisitVariableProxy 
(this=0x7fffffffa530, expr=0xad64b0) at src/PrettyPrinter.cpp:1420
#6  0x00007ffff4557025 in Visit (node=<optimized out>, this=0x7fffffffa530) at 
src/PrettyPrinter.h:47
#7  Visit (node=<optimized out>, this=0x7fffffffa530) at 
src/PrettyPrinter.cpp:1583
#8  v8::internal::JsonAstBuilder::VisitVariableDeclaration 
(this=0x7fffffffa530, decl=0xad6500) at src/PrettyPrinter.cpp:1589
#9  0x00007ffff45822da in 
v8::internal::AstVisitor::VisitDeclarations(v8::internal::ZoneList<v8::internal:
:Declaration*>*) () from 
/home/buffer/.python-eggs/PyV8-1.0_dev-py2.7-linux-x86_64.egg-tmp/_PyV8.so
#10 0x00007ffff4556e2a in v8::internal::JsonAstBuilder::VisitFunctionLiteral 
(this=0x7fffffffa530, expr=0xad6848) at src/PrettyPrinter.cpp:1392
#11 0x00007ffff45566e5 in Visit (node=0xad6848, this=0x7fffffffa530) at 
src/PrettyPrinter.h:47
#12 Visit (node=0xad6848, this=0x7fffffffa530) at src/PrettyPrinter.cpp:1208
#13 v8::internal::JsonAstBuilder::BuildProgram (this=0x7fffffffa530, 
program=0xad6848) at src/PrettyPrinter.cpp:1210
#14 0x00007ffff45308cb in CAstFunctionLiteral::ToJSON (this=<optimized out>) at 
src/AST.h:720
[..]

Please let me know if you need additional details.

Original issue reported on code.google.com by angelo.d...@gmail.com on 13 Dec 2013 at 8:58

GoogleCodeExporter commented 8 years ago
i can confirm that I get the same segfault under r560 using both of the 
following:
ubuntu 12.04
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
v8/trunk r18331
libboost1.48-all-dev
python 2.7.3

and

osx 10.9
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
v8/trunk r18331
boost 1.55 via brew
python 2.7.6

any python call to prog.toJSON triggers the segfault in:
gdb --args python callgraph.py commonjs/program.js
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff68f63b1 in _IO_vfprintf_internal (s=<optimized out>, 
format=<optimized out>, ap=<optimized out>)
    at vfprintf.c:1630
1630    vfprintf.c: No such file or directory.

Original comment by reds...@gmail.com on 17 Dec 2013 at 10:32

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Also, whenever the setup.py is told to use DEBUG mode, PyV8 fails to link with 
duplicate symbol errors:

../thug/utils/v8/out/../src/prettyprinter.cc:1161: multiple definition of 
`v8::internal::AstPrinter::VisitThisFunction(v8::internal::ThisFunction*)'
build/temp.linux-x86_64-2.7/src/PrettyPrinter.o:../thug/utils/pyv8/src/PrettyPri
nter.cpp:1156: first defined here
collect2: ld returned 1 exit status
error: command 'g++' failed with exit status 1

duplicate symbol __ZTSN2v88internal10AstPrinterE in:
    build/temp.macosx-10.9-x86_64-2.7/src/PrettyPrinter.o
    ../thug/utils/v8/out/x64.debug//libv8_base.x64.a(prettyprinter.o)
ld: 130 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang++' failed with exit status 1

and the setup.py also doesn't take into account Boost's debug libs 
libboost_python-d and libboost_python-mt-d, etc.

a simple patch would be:
--- setup.py-old    2013-12-17 17:41:42.000000000 -0500
+++ setup.py    2013-12-17 17:41:16.000000000 -0500
@@ -137,6 +137,8 @@

 if BOOST_MT:
     boost_libs = [lib + '-mt' for lib in boost_libs]
+if DEBUG:
+    boost_libs = [lib + '-d' for lib in boost_libs]

 include_dirs = [
     os.path.join(V8_HOME, 'include'),

Original comment by reds...@gmail.com on 17 Dec 2013 at 10:43

GoogleCodeExporter commented 8 years ago
The root cause is PyV8 use * operator of SmartPointerBase, but V8 has changed 
its behaviors.

Please verify the fix with SVN trunk code after r563

Original comment by flier...@gmail.com on 24 Dec 2013 at 4:21

GoogleCodeExporter commented 8 years ago
Verified for me.

Original comment by es...@mrfjo.org on 24 Dec 2013 at 9:44

GoogleCodeExporter commented 8 years ago
Thanks

Original comment by flier...@gmail.com on 25 Dec 2013 at 2:08