From: CVKEWCZBUTBW at spammotel dot com Operating system: Solaris PHP version: Irrelevant PHP Bug Type: iPlanet related Bug description: Extensions cannot be loaded dynamically on Solaris / iPlanet
Description: ------------ I attempt to load a PHP extension (namely, the Java extension) dynamically in a Solaris / iPlanet environment. Actual result: -------------- I get this log message: [08-Jul-2003 16:19:08] PHP Warning: Unable to load dynamic library '/usr/local/php-4.2.1_gd_java/lib/php/extensions/no-debug-zts-20020429/java.so' - ld.so.1: ns-httpd: fatal: relocation error: file /usr/local/php-4.2.1_gd_java/lib/php/extensions/no-debug-zts-20020429/java.so: symbol core_globals_id: referenced symbol not found in Unknown on line 0 This is reproducible on PHP 4.2.1 and on PHP 4.3.2. The reason for this problem is as follows: ------------------------------------------ The web server loads the PHP module through "dlopen()". iPlanet, obviously opposed to Apache, does not set the RTLD_GLOBAL option when calling "dlopen()", which means that the PHP core symbols are not published. Consequently, when PHP loads an extension with "dlopen()", then that extension does not see the PHP core symbols (the first of which is "core_globals_id"). iPlanet obviously has no option to set the RTLD_GLOBAL flag when loading the PHP module. One solution is as follows: --------------------------- An extension can "see" the PHP core symbols if PHP sets the "RTLD_PARENT" option when loading the extension. The patch required to achieve this is: *** Zend/zend.h.orig Wed Jul 9 17:25:37 2003 --- Zend/zend.h Wed Jul 9 17:43:32 2003 *************** *** 73,79 **** # define RTLD_GLOBAL 0 # endif ! # define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL) # define DL_UNLOAD dlclose # if DLSYM_NEEDS_UNDERSCORE # define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" ## s) --- 73,80 ---- # define RTLD_GLOBAL 0 # endif ! /* AU 2003-07-09 */ ! # define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL |RTLD_PARENT|RTLD_GROUP|RTLD_WORLD) # define DL_UNLOAD dlclose # if DLSYM_NEEDS_UNDERSCORE # define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" ## s) In other words: The "RTLD_PARENT|RTLD_GROUP|RTLD_WORLD" options must be added to the "dlopen()" call. This patch was tested with PHP 4.2.1. The buggy line of code exists in all of versions 4.2.1, 4.3.2 and 5.0.0 beta, so I strongly presume that the problem exists in all PHP versions and that the fix also works for all PHP versions. I have no clue if the code change I made is suitable for other environments and cofigurations. This requires regression testing on other platforms, which I cannot do. I believe someone from the PHP team should make a decision here. -- Edit bug report at http://bugs.php.net/?id=24582&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24582&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24582&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=24582&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24582&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24582&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24582&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24582&r=support Expected behavior: http://bugs.php.net/fix.php?id=24582&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24582&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24582&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24582&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24582&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24582&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24582&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24582&r=gnused
