Symbol clash between Recode and MySQL extensions

php.internals

Unnamed Person

21 years ago
On FreeBSD, I was gettting the following error message when PHP exits: Php in free(): junk pointer, too high to make sense Further investigation showed that it stops showing when the MySQL module is disabled. I rebuilt my MySQL client libraries with debugging symbols, and forced a crash on invalid frees. Here is a backtrace: (gdb) bt #0 0x283fb404 in kill () from /usr/lib/libc.so.4 #1 0x28440810 in abort () from /usr/lib/libc.so.4 #2 0x2843f18a in isatty () from /usr/lib/libc.so.4 #3 0x2843f1bf in isatty () from /usr/lib/libc.so.4 #4 0x28440208 in isatty () from /usr/lib/libc.so.4 #5 0x28440485 in free () from /usr/lib/libc.so.4 #6 0x28487962 in my_no_flags_free (ptr=0x28d365e8 "U\211å\203ì\024Sèðÿÿÿ\201ÃXo\017") at my_malloc.c:60 #7 0x2848c7a6 in delete_dynamic (array=0x824b798) at array.c:236 #8 0x2848ddad in hash_free (hash=0x824b780) at hash.c:116 #9 0x28d38b74 in recode_delete_outer () from /usr/local/lib/librecode.so.3 #10 0x28ceed88 in zm_shutdown_recode () from /usr/local/lib/php/20041030/recode.so #11 0x81145be in module_destructor () #12 0x81170d7 in zend_hash_apply_deleter () #13 0x8117246 in zend_hash_graceful_reverse_destroy () #14 0x810faa2 in zend_shutdown () #15 0x80d8a10 in php_module_shutdown () #16 0x8157eea in main () #17 0x80632a1 in _start () It looks like the MySQL hash_free function is being called as the recode extension shuts down. I confirmed this by disabling the recode module and noting that the problem went away (it also goes away if the MySQL module is disabled). Any thoughts on how to scope the libraries to avoid this conflict? I was thinking dlfunc could be used to only import the functions we want, but I don't really have time to play with this myself.
-- Alastair D'Silva mob: 0413 485 733 Networking Consultant fax: 0413 181 661 New Millennium Networking web: http://www.newmillennium.net.au

Wez Furlong

21 years ago
I think you should be talking to the people that wrote those two libraries to ask them to clean up their exports; it's nothing to do with PHP. For a quick "fix", I'd suggest dropping recode and using iconv instead. --Wez. On Sun, 13 Feb 2005 16:24:42 +1100, php@newmillennium.net.au <php@newmillennium.net.au> wrote:

Jani Taskinen

21 years ago
Also documented in the manual: http://www.php.net/recode Just blame recode and mysql. They both should namespace protect their functions. :) If you build the extensions as shared ones, then you can always make sure in php.ini that you load recode.so first.. --Jani On Sun, 13 Feb 2005 php@newmillennium.net.au wrote:

Unnamed Person

21 years ago
> -----Original Message----- > From: Jani Taskinen [mailto:sniper@iki.fi] > Sent: Sunday, 13 February 2005 5:25 PM > To: php@newmillennium.net.au > Cc: internals@lists.php.net > Subject: Re: [PHP-DEV] Symbol clash between Recode and MySQL > extensions > > > > Also documented in the manual: > > http://www.php.net/recode
Got it, thanks.
> Just blame recode and mysql. They both should namespace > protect their > functions. :)
Agreed. However, if a workaround is available, it would benefit everyone to implement it. I was thinking that rather than linking against the recode library (and implicitly importing all symbols within it), we could instead dlopen() it, and use dlsym() to import only symbols we want. Looking at the recode extension, theres only a handful of entrypoints that need to be imported, so it should be a relatively easy task for someone familiar with the PHP API.
-- Alastair D'Silva mob: 0413 485 733 Networking Consultant fax: 0413 181 661 New Millennium Networking web: http://www.newmillennium.net.au

Derick Rethans

21 years ago
On Sun, 13 Feb 2005 php@newmillennium.net.au wrote:
> I was thinking that rather than linking against the recode library (and > implicitly importing all symbols within it), we could instead dlopen() it, > and use dlsym() to import only symbols we want. Looking at the recode > extension, theres only a handful of entrypoints that need to be imported, so > it should be a relatively easy task for someone familiar with the PHP API.
I still think that's going a bit too far, besides, recode offers no advantages over iconv (and some recode versions are quite buggy). So I suggest to use iconv instead of recode. regards, Derick
-- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org