|  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
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);

        /* 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:

then run:

php -m | grep -i pdo

Expected result:

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

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

Trace/BPT trap


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-12 16:45 UTC]
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]
Assigned to our MacOSX expert. :)
 [2007-09-13 10:12 UTC]
See also bug #42630
 [2007-09-13 15:50 UTC]
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]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 13:01:27 2024 UTC