chuan-yun / Molten

php probe for zipkin and opentracing
Apache License 2.0
793 stars 160 forks source link

Can't load extension #23

Closed remicollet closed 6 years ago

remicollet commented 7 years ago

PHP Warning: PHP Startup: Unable to load dynamic library 'modules/molten.so' - modules/molten.so: undefined symbol: MOLTEN_ERROR in Unknown on line 0

And indeed, lot of -Wimplicit-function-declaration during the build, some of them

/tmp/Molten-0.1.0beta/php7_wrapper.h:245:5: attention : implicit declaration of function « php_array_merge_recursive » [-Wimplicit-function-declaration]
/tmp/Molten-0.1.0beta/molten.c:681:5: attention : implicit declaration of function « mo_intercept_uninit » [-Wimplicit-function-declaration]
/tmp/Molten-0.1.0beta/molten.c:643:5: attention : implicit declaration of function « mo_intercept_init » [-Wimplicit-function-declaration]
/tmp/Molten-0.1.0beta/molten.c:557:5: attention : implicit declaration of function « mo_shm_ctor » [-Wimplicit-function-declaration]
/tmp/Molten-0.1.0beta/molten_ctrl.c:178:17: attention : implicit declaration of function « check_hit_ratio » [-Wimplicit-function-declaration]
/tmp/Molten-0.1.0beta/common/molten_shm.c:28:9: attention : implicit declaration of function « MOLTEN_ERROR » [-Wimplicit-function-declaration]
/tmp/Molten-0.1.0beta/common/molten_lock.c:151:9: attention : implicit declaration of function « unlink » [-Wimplicit-function-declaration]
/tmp/Molten-0.1.0beta/common/molten_lock.c:162:5: attention : implicit declaration of function « close » [-Wimplicit-function-declaration]
/tmp/Molten-0.1.0beta/molten_chain.c:121:9: attention : implicit declaration of function « rand64hex » [-Wimplicit-function-declaration]
...
remicollet commented 7 years ago

this RTLD_LAZY dl open hide such issue (with standard PHP build), with RTLD_NOW (in linux distro) you can't load the extension (btw, IMHO, better than segfault at runtime)

More information on https://derickrethans.nl/undefined-symbol.html

atul016 commented 7 years ago

i am also getting PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/molten.so' - /usr/lib64/php/modules/molten.so: undefined symbol: php_json_decode_ex in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/molten.so' - /usr/lib64/php/modules/molten.so: undefined symbol: php_pdo_get_exception in Unknown on line 0

tried adding extension=json.so before of extension=molten.so in php.ini then the warning becomes PHP Warning: Module 'json' already loaded in Unknown on line 0 PHP Warning: Module 'PDO' already loaded in Unknown on line 0

remicollet commented 7 years ago

@atul016 load order matters, so molten shoudl be loaded "after" json, curl and pdo

silkcutKs commented 7 years ago

@remicollet @atul016 i am already load molten after json/curl/pdo

static const zend_module_dep molten_deps[] = {
    ZEND_MOD_REQUIRED("json")
    ZEND_MOD_REQUIRED("standard")
    ZEND_MOD_REQUIRED("curl")
    ZEND_MOD_OPTIONAL("memcached")    
    ZEND_MOD_OPTIONAL("redis")    
    ZEND_MOD_OPTIONAL("mongodb")    
    ZEND_MOD_OPTIONAL("mysqli")    
    ZEND_MOD_OPTIONAL("PDO")    
    ZEND_MOD_END
};

@remicollet other problem resovling

remicollet commented 7 years ago

@silkcutKs no. ZEND_MOD_REQUIRED only manage "init" order.

With RTLD_NOW (see above link), load order (so extension directives order) matters.

The reason why, linux distro, use a numerical prefix for configuration file. Example on Fedora, in /etc/php.d

20-curl.ini
20-json.ini
20-pdo.ini
30-mysqli.ini  # after 20-mysqlnd...
50-memcached.ini # after 40-igbinary...
50-mongodb.ini 
50-redis.ini
60-molten.ini # use 60 to be great than all deps.
remicollet commented 7 years ago

@atul016 which distro are you using ?

silkcutKs commented 7 years ago

@remicollet I have verify the issue at my build version replace RTLD_LAZY with RTLD_NOW, the problem exist. have other method to solve the problem?

silkcutKs commented 7 years ago

@remicollet some error i have remove.

remicollet commented 7 years ago

have other method to solve the problem?

No, load order have to be managed.

People using distro packages for PHP should NOT install extension from sources, but also use distro packkages ;) and thus, this is a downstream issue.

remicollet commented 7 years ago

@silkcutKs indeed, undefined symbols are fixed (but still have lot of -Wimplicit-function-declaration)

$ php -n -d extension=json.so -d extension=curl.so -d extension=pdo.so -d extension=modules/molten.so -m
[PHP Modules]
Core
curl
date
filter
hash
json
libxml
molten
openssl
pcntl
pcre
PDO
readline
Reflection
session
SPL
standard
zlib

[Zend Modules]
silkcutKs commented 7 years ago

@remicollet thankyou for verify. BTW, molten tracing extension detail infomation, sometimes need the extension internal function. if the user tracing their app, they should build from source to adapt their env.

remicollet commented 7 years ago

@silkcutKs do you mean it doesn't make sense to provide binary package for this extension ?

(FYI see: https://blog.remirepo.net/pages/PECL-extensions-RPM-status)

silkcutKs commented 7 years ago

@remicollet there is some limits for molten. here is hard deps extension : json, standard,curl.(without this, can not run) soft deps : mysqli, pdo(without this, can not support full functions)

if provide binnary package, i think the full functions supported is good. do you have some suggest????

remicollet commented 7 years ago

@silkcutKs of course, for downstream distribution, all ZENDMOD described dependencies will be available (as package dependencies)

silkcutKs commented 7 years ago

@remicollet
All I want to say is "all dependecies will be available is great!!!"

remicollet commented 7 years ago

@remicollet the distribution that we support complete functions to urge users to add other extension, is that ok?

Sorry, haven't understood

silkcutKs commented 7 years ago

@remicollet
All I want to say is "all dependecies will be available is great!!!"

atul016 commented 7 years ago

@remicollet i am using CentOS Linux release 7.3.1611

remicollet commented 7 years ago

@atul016 so, use my repo, you will have most possible extensions available ;)

And this one will be available, as soon as a new release fixing this issue will be published

remicollet commented 7 years ago

FYI: https://twitter.com/RemiRepository/status/898093545575395328

silkcutKs commented 7 years ago

@atul016 please use remi repo, it is really comfortable for phper to manager extension.