Bug #74293 [Opn]: Order of extensions loaded in php.ini affects function calls
Edit report at https://bugs.php.net/bug.php?id=74293&edit=1
ID: 74293
Updated by: ab@php.net
Reported by: yukiwongky at gmail dot com
Summary: Order of extensions loaded in php.ini affects
function calls
Status: Open
Type: Bug
Package: Dynamic loading
Operating System: Darwin
PHP Version: 7.1.3
Block user comment: N
Private report: N
New Comment:
Seems Nikita's guess is exactly what happens. There maybe several scenarios, but all are
related to the actual linker and loader process. For example the loader might only use the first
refered symbol it finds, if the DSOs export duplicated symbols. Another situation, if some DSO was
linked the way, that some library overrides symbols in the object files. The symbol in the signature
you show should not be exported, however it could happen if compiler does it by default. It is quite
possible, that the system loader will only use the symbol encountered first.
The extensions are not the core PHP extensions, so it doesn't look like a core bug. I'd
suggest first to consult your compiler documentation and ensure the symbols not explicitly exported
are kept private in the binaries.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2017-03-22 20:10:10] yukiwongky at gmail dot com
The examples I found in the sqlsrv and pdo_sqlsrv extensions are:
sqlsrv_error_const* get_error_message(unsigned int sqlsrv_error_code);
struct stmt_option_ss_scrollable : public stmt_option_functor {
virtual void operator()( sqlsrv_stmt* stmt, stmt_option const* /*opt*/, zval* value_z TSRMLS_DC
);
};
------------------------------------------------------------------------
[2017-03-22 19:53:41] nikic@php.net
What linkage and visibility does your C function use? (If you don't know, can you paste the
complete function signature, including any attributes before it?)
------------------------------------------------------------------------
[2017-03-22 19:48:34] yukiw at simba dot com
he C functions that my extension defines
------------------------------------------------------------------------
[2017-03-22 19:42:28] nikic@php.net
When you say "function", are you referring to PHP functions registered by your extension,
or to C functions that your extension defines?
------------------------------------------------------------------------
[2017-03-22 19:38:27] yukiwongky at gmail dot com
Description:
------------
This only happens in Mac (I've tested it on Sierra and Al Capital, but I'm not sure if
older Mac OS versions have this problem. But Windows and Linux (Ubuntu and CentOS) don't seem
to have this problem.
I have two extensions and they have a few common function names. When I use these extensions in
Windows or Linux, the order in which I put them in php.ini doesn't matter. However, when I use
the extensions on Mac, the function that is in the first loaded extension is always called. For
example, I have extension A and B. When I'm using API's from B, I would expect the
function in B to be called. However, if I loaded A before B in php.ini, the function of the same
name in A is called.
For now I have managed to have a workaround for it by changing the function names / putting them
into their own namespace. However, I am concerned that what if some other extension that's not
created by me also have the same function names as the ones in my extensions and some user load that
extension before mine.
Expected result:
----------------
I expect to see the order of which I load the extensions do not affect which function of the common
name is called.
Actual result:
--------------
The function of the extension that is loaded first is executed.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74293&edit=1
Thread (8 messages)