php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42629 Dynamically loaded PHP extensions need symbols exported
Submitted: 2007-09-11 20:05 UTC Modified: 2007-09-18 09:25 UTC
From: jdolecek at NetBSD dot org Assigned:
Status: Closed Package: Dynamic loading
PHP Version: 5.2.4 OS: Mac OS X 10.4.10
Private report: No CVE-ID: None
 [2007-09-11 20:05 UTC] jdolecek at NetBSD dot org
Description:
------------
Some PHP extensions expect to have symbols from other PHP extensions available. This is the case for PDO drivers (which use symbols from PDO extension) and XSL (which uses symbols from DOM extension).

Extensions are loaded with dlopen(..., RTLD_GLOBAL) on platforms with dlopen() (i.e. most unices). On Mac OS X, NSLinkModule() is used instead of dlopen(), but with 'private' option, which hides symbols of dynamically loaded extensions from other dynamically loaded code.

Due to this symbol hiding, PDO and DOM needed to be compiled into base PHP binary, otherwise the dependant extension couldn't be dynamically loaded since expected symbols are not found. PDO configure script even intentionally silently disables compilation of dynamically loaded PDO module on MacOSX/Darwin because of this.

Following patch makes it possible to load also PDO and DOM dynamically on Mac OS X and thus PHP extensions work all the same way as on other UNIX systems:

--- Zend/zend_extensions.c.orig 2007-09-11 22:00:50.000000000 +0200
+++ Zend/zend_extensions.c
@@ -243,7 +243,7 @@ void *zend_mh_bundle_load(char* bundle_p
                return NULL;
        }

-       bundle_handle = NSLinkModule(bundle_image, bundle_path, NSLINKMODULE_OPTION_PRIVATE);
+       bundle_handle = NSLinkModule(bundle_image, bundle_path, NSLINKMODULE_OPTION_NONE);
        NSDestroyObjectFileImage(bundle_image);

        /* call the init function of the bundle */








Reproduce code:
---------------
Compile PDO (after fix to configure script) as dynamic extensions, as well as pdo_mysq, and add into php.ini lines:

extension=pdo.so
extension=pdo_mysql.so

then run:

php -m | grep -i pdo

Expected result:
----------------
PDO
pdo_mysql


Actual result:
--------------
dyld: lazy symbol binding failed: Symbol not found: _php_pdo_declare_long_constant
  Referenced from: /Users/Shared/pkg/lib/php/20040412/pdo_mysql.so
  Expected in: flat namespace

dyld: Symbol not found: _php_pdo_declare_long_constant
  Referenced from: /Users/Shared/pkg/lib/php/20040412/pdo_mysql.so
  Expected in: flat namespace

Trace/BPT trap


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-12 16:45 UTC] kalowsky@php.net
When this code was originally written, PDO didn't exist and as such the choice to use the PRIVATE option was made to keep the namespace the least polluted possible.  Having not tested the patch, the changes make sense and probably should be applied provided they don't cause any adverse affects to other files included.
 [2007-09-13 10:12 UTC] jani@php.net
Assigned to our MacOSX expert. :)
 [2007-09-13 10:12 UTC] jani@php.net
See also bug #42630
 [2007-09-13 15:50 UTC] kalowsky@php.net
Unfortunately due to outside circumstance to the project, I cannot take ownership and commit a fix to this bug at this time.  I strongly encourage you Jani to apply the fix though.
 [2007-09-18 09:25 UTC] jani@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC