phpv8 / v8js

V8 Javascript Engine for PHP — This PHP extension embeds the Google V8 Javascript Engine
http://pecl.php.net/package/v8js
MIT License
1.83k stars 200 forks source link

v8js: v8js.so: undefined symbol: _ZSt25__throw_bad_function_callv in Unknown on line 0 #204

Closed serenityzn closed 8 years ago

serenityzn commented 8 years ago

Hello,

I have compiled v8js (0.4.1 version) following README.Linux instructions. Everything compiled fine but when php trying to load v8js extension it returns me an error: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/v8js.so' - /usr/lib64/php/modules/v8js.so: undefined symbol: _ZSt25__throw_bad_function_callv in Unknown on line 0

System: Centos 6.6. V8 version: 4.3.9 (build string: make native library=shared snapshot=off -j8) GCC version: gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Also I have tried to install via pecl: installed succesfully but the same error when php tried to load extension.

I will be grateful for help. Thank you in advance, Volodymyr

stesie commented 8 years ago

Have you checked whether V8 as compiled by you is working? e.g. by running some of their sample scripts like out/native/hello-world or out/native/shell

_ZSt25__throw_bad_function_callv is the mangled name for std::__throw_bad_function_call() symbol which should be exported by libstdc++

https://stackoverflow.com/questions/12942538/undefined-symbol-std-throw-bad-function-call might be related

Do you have multiple c++ library versions around? Or just some normal Centos installation?

serenityzn commented 8 years ago

Yes I have cheked V8 - it's working fine: v8]# out/native/shell V8 version 4.3.9 [sample shell]

print('hello world'); hello world

Yes I have multiple c++ libraries. I have installed devtoolset-2 with gcc 4.8.2. and used them to build v8 and v8js. But system GCC version is 4.4.7.

Enase commented 8 years ago

Hi guys, I have the same troubles. Any suggestion is very welcome! Thanks in advance.

stesie commented 8 years ago

@Enase you're on Centos as well?

Enase commented 8 years ago

cat /etc/centos-release CentOS release 6.7 (Final)

Enase commented 8 years ago

@stesie pls, let me know if you need any additional info.

stesie commented 8 years ago

@Enase sure I'll let you know. Unfortunately I haven't found time to set up a CentOS box yet

stesie commented 8 years ago

Sorry for the late reply, but I finally found some time to spend on CentOS - after all it was a little bit more involved than I expected initially but ...

First of all I tried with a more recent version of CentOS (7.2) without any major issue

Then I tried CentOS 6.7 with python 2.7 (for the V8 build process) + devtoolset-2 as mentioned by both of you... and finally able to reproduce the problem both of you have.

The problem is that the base system's libstdc++.so is pretty old and lacks support for recent C++ features (which are used by php-v8js however). The devtoolset-2 package ships a libstdc++.so linker script that uses the base system's version and augments its with a static library that has the other stuff.

The linker script /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libstdc++.so says

/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-x86-64)
INPUT ( /usr/lib64/libstdc++.so.6 -lstdc++_nonshared )

The base library /usr/lib64/libstdc++.so.6 doesn't have the symbol missing (from above):

[root@2ced09d8fe23 php-5.5.32]# nm -D /usr/lib64/libstdc++.so.6 | grep _ZSt25__throw_bad_function_callv

however the extra library has it:

[root@2ced09d8fe23 php-5.5.32]# nm /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libstdc++_nonshared.a  | grep _ZSt25__throw_bad_function_callv
0000000000000000 T _ZSt25__throw_bad_function_callv

... for normal programs this is no problem, the linker just links the necessary stuff from the static library right into the program and uses the shared library for the rest.

With v8js this is a problem however as it isn't linked as a program but as a shared library itself ... and therefore the symbols from the static library are not linked in. ... and the PHP binary itself was compiled earlier (by the package distributor) of course not linking in those symbols as well.

A solution to the problem would be statically linking v8js into php itself (i.e. recompile php and do the static linking mentioned above); I just tried that and confirm it working.

hope that helps :-)

~stesie

Enase commented 8 years ago

Thanks, it works for me.

rosmo commented 8 years ago

Hey @Enase, you could also try the RPM specs for EL6 and EL7 for newer V8s: https://github.com/rosmo/v8-rpm