php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53005 iconv() fails in ext/iconv/iconv.c php_iconv_string
Submitted: 2010-10-06 22:58 UTC Modified: 2010-10-07 01:45 UTC
From: php at jdrtech dot com Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3.3 OS: Solaris 10 Sparc
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at jdrtech dot com
New email:
PHP Version: OS:

 

 [2010-10-06 22:58 UTC] php at jdrtech dot com
Description:
------------
PHP runs great with the exception of iconv. I've created a test program that uses libiconv.so.2.5.0 with expected results

CLI command:

>./php ./test.php
Original : This is the Euro symbol '?'.
TRANSLIT : Segmentation Fault (core dumped)

CC: Sun C++ 5.8 2005/10/13
cc: Sun C 5.8 2005/10/13

Configure:

export CC=cc CFLAGS="-xarch=v9a" CXXFLAGS="-xarch=v9a" CPPFLAGS="-I/fcgi/include" LDFLAGS="-L/fcgi/lib"

./configure --prefix=/fcgi --with-mysql=/opt/mysql/mysql --enable-mbstring --with-apache=../apache_1.3.41 -with-dom --with-xsl=/fcgi --with-iconv-dir=/fcgi --enable-debug

>ldd php
        libexslt.so.0 =>         /fcgi/lib/libexslt.so.0
        libpthread.so.1 =>       /lib/64/libpthread.so.1
        libsocket.so.1 =>        /lib/64/libsocket.so.1
        libnsl.so.1 =>   /lib/64/libnsl.so.1
        libm.so.2 =>     /lib/64/libm.so.2
        librt.so.1 =>    /lib/64/librt.so.1
        libmysqlclient.so.16 =>  /usr/local/mysql/lib/libmysqlclient.so.16
        libthread.so.1 =>        /lib/64/libthread.so.1
        libxslt.so.1 =>  /fcgi/lib/libxslt.so.1
        libxml2.so.2 =>  /fcgi/lib/libxml2.so.2
        libresolv.so.2 =>        /lib/64/libresolv.so.2
        libgen.so.1 =>   /lib/64/libgen.so.1
        libiconv.so.2 =>         /fcgi/lib/libiconv.so.2
        libc.so.1 =>     /lib/64/libc.so.1
        libz.so.1 =>     /usr/lib/64/libz.so.1
        libmp.so.2 =>    /lib/64/libmp.so.2
        libmd5.so.1 =>   /lib/64/libmd5.so.1
        libscf.so.1 =>   /lib/64/libscf.so.1
        libaio.so.1 =>   /lib/64/libaio.so.1
        libdoor.so.1 =>  /lib/64/libdoor.so.1
        libuutil.so.1 =>         /lib/64/libuutil.so.1
        /platform/SUNW,Sun-Blade-100/lib/sparcv9/libc_psr.so.1
        /platform/SUNW,Sun-Blade-100/lib/sparcv9/libmd5_psr.so.1



Test script:
---------------
<?php
$text = "This is the Euro symbol '?'.";

echo 'Original : ', $text, PHP_EOL;
echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL;
echo 'IGNORE   : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL;
echo 'Plain    : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;

?>


Expected result:
----------------
unknown

Actual result:
--------------
t@1 (l@1) program terminated by signal SEGV (no mapping at the fault address)
0xffffffff7d35a544: _iconv+0x002c:      jmp      %l5
Current function is php_iconv_string
  501                   result = iconv(cd, (char **) &in_p, &in_left, (char **) &out_p, &out_left);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-07 01:45 UTC] php at jdrtech dot com
-Status: Open +Status: Closed
 [2010-10-07 01:45 UTC] php at jdrtech dot com
needed to do preload, runs great
 [2010-10-13 12:26 UTC] reggaedancer at ymail dot com
Hello, 
I have the same issue on Solaris 10 x86,
PHP 5.3.3
after running iconv PHP script, PHP crashed and created a core dump.
What do you mean by "needed to preload".
How can I fix this issue ?
 [2010-10-13 15:12 UTC] wes at jdrtech dot com
libiconv should provide the preloadable library preloadable_libiconv.so.

I edited apachectl:

--------------------------------------

 case $ARG in
    start)
        LD_PRELOAD_64=/fcgi/lib/preloadable_libiconv.so
        export LD_PRELOAD_64

        if [ $RUNNING -eq 1 ]; then
            echo "$0 $ARG: httpd (pid $PID) already running"
            continue
        fi
------------------------------------

of course your library location may differ, probably /usr/local/lib and LD_PRELOAD_32 if your using 32 bit

good luck
 [2010-10-14 18:18 UTC] reggaedancer at ymail dot com
Ubelievable!!
It really works.
I just added:
LD_PRELOAD_32=/usr/local/lib/preloadable_libiconv.so
export LD_PRELOAD_32
and the Apache/PHP with iconv is working and not crashing anymore.

I tried to use disable_functions in PHP to avoid iconv,
but this preload solution is great.
Thank you very much for your help.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 19:01:29 2024 UTC