|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-11-15 21:48 UTC] dkelsey at bstage dot ca
Description:
------------
using iconv() within a php script segfaults when converting a UTF-8 string to ISO-8859-1
I downloaded and compiled gnu libiconv-1.14 into /opt/local
My php configure
./configure '--prefix=/opt/bstage/php5.3.8' \
'--with-apxs2=/opt/bstage/apache2.2.21-php/bin/apxs' \
'--enable-bcmath' \
'--enable-mbstring' \
'--with-zlib' \
'--with-config-file-path=/opt/bstage/php5.3.8/lib' \
'--with-xsl' \
'--with-xmlrpc' \
'--with-regex=system' \
'--without-sqlite' \
'--disable-posix' \
'--enable-dom' \
'--disable-pdo' \
'--enable-xml' \
'--with-libxml-dir=/opt/local' \
'--enable-ipv6' \
'--host=i386-sun-solaris2' \
'--mandir=/opt/local/man' \
'--with-gd' \
'--with-mysql=/opt/mysql-5.5.8-solaris10-i386' \
'--with-mysqli=/opt/mysql-5.5.8-solaris10-i386/bin/mysql_config' \
'--with-curl=/opt/local' \
'--enable-debug'
ldd php
libexslt.so.0 => /usr/lib/libexslt.so.0
libresolv.so.2 => /lib/libresolv.so.2
libmysqlclient.so.16 => /opt/mysql-5.5.8-solaris10-i386/lib/libmysqlclient.so.16
libiconv.so.2 => /opt/local/lib/libiconv.so.2
libpng12.so.0 => /usr/lib/libpng12.so.0
libz.so.1 => /usr/lib/libz.so.1
librt.so.1 => /lib/librt.so.1
libm.so.2 => /lib/libm.so.2
libnsl.so.1 => /lib/libnsl.so.1
libsocket.so.1 => /lib/libsocket.so.1
libxml2.so.2 => /usr/lib/libxml2.so.2
libcurl.so.4 => /opt/local/lib/libcurl.so.4
libssl.so.0.9.7 => /usr/sfw/lib/libssl.so.0.9.7
libcrypto.so.0.9.7 => /usr/sfw/lib/libcrypto.so.0.9.7
libldap.so.5 => /usr/lib/libldap.so.5
libdl.so.1 => /lib/libdl.so.1
libthread.so.1 => /lib/libthread.so.1
libxslt.so.1 => /usr/lib/libxslt.so.1
libc.so.1 => /lib/libc.so.1
libpthread.so.1 => /lib/libpthread.so.1
libgcc_s.so.1 => /usr/sfw/lib/libgcc_s.so.1
libaio.so.1 => /lib/libaio.so.1
libmd.so.1 => /lib/libmd.so.1
libmp.so.2 => /lib/libmp.so.2
libscf.so.1 => /lib/libscf.so.1
libsasl.so.1 => /usr/lib/libsasl.so.1
libnspr4.so => /usr/lib/mps/libnspr4.so
libplc4.so => /usr/lib/mps/libplc4.so
libnss3.so => /usr/lib/mps/libnss3.so
libssl3.so => /usr/lib/mps/libssl3.so
libdoor.so.1 => /lib/libdoor.so.1
libuutil.so.1 => /lib/libuutil.so.1
libgen.so.1 => /lib/libgen.so.1
libsoftokn3.so => /usr/lib/mps/libsoftokn3.so
libplds4.so => /usr/lib/mps/libplds4.so
libbsm.so.1 => /lib/libbsm.so.1
libsecdb.so.1 => /lib/libsecdb.so.1
libtsol.so.2 => /lib/libtsol.so.2
libcmd.so.1 => /lib/libcmd.so.1
libssl_extra.so.0.9.7 => /usr/sfw/lib/libssl_extra.so.0.9.7
libcrypto_extra.so.0.9.7 => /usr/sfw/lib/libcrypto_extra.so.0.9.7
I've used truss and gdb and get a segfault.
Test script:
---------------
<?php
error_reporting(E_ALL);
/*
$text = utf8_encode("Dave Kelsey");
*/
$text = "Dave Kelsey";
echo 'Original : ', $text, PHP_EOL;
echo 'Plain : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;
?>
Expected result:
----------------
Original : Dave Kelsey
Plain : Dave Kelsey
Actual result:
--------------
./php -ef iconv.php
Original : Dave Kelsey
Plain : Segmentation Fault (core dumped)
Note: the parsing of the string takes about 3-4 seconds?
gdb ./php -c core
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-pc-solaris2.9"...
Reading symbols from /opt/local/lib/libexslt.so.0...done.
Loaded symbols for /opt/local/lib/libexslt.so.0
Reading symbols from /opt/local/lib/libgcrypt.so.11...done.
Loaded symbols for /opt/local/lib/libgcrypt.so.11
Reading symbols from /opt/local/lib/libgpg-error.so.0...done.
Loaded symbols for /opt/local/lib/libgpg-error.so.0
Reading symbols from /lib/libsocket.so.1...done.
Loaded symbols for /lib/libsocket.so.1
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libm.so.2...done.
Loaded symbols for /lib/libm.so.2
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /opt/mysql/mysql-5.5.16/lib/libmysqlclient.so.18...done.
Loaded symbols for /opt/mysql/mysql-5.5.16//lib/libmysqlclient.so.18
Reading symbols from /opt/local/lib/libfreetype.so.6...done.
Loaded symbols for /opt/local/lib/libfreetype.so.6
Reading symbols from /opt/local/usr/local/lib/libpng12.so.0...done.
Loaded symbols for /opt/local/usr/local/lib/libpng12.so.0
Reading symbols from /opt/local/lib/libjpeg.so.8...done.
Loaded symbols for /opt/local/lib/libjpeg.so.8
Reading symbols from /lib/librt.so.1...
warning: Lowest section in /lib/librt.so.1 is .dynamic at 00000074
done.
Loaded symbols for /lib/librt.so.1
Reading symbols from /opt/local/lib/libcurl.so.4...done.
Loaded symbols for /opt/local/lib/libcurl.so.4
Reading symbols from /opt/local/lib/libidn.so.11...done.
Loaded symbols for /opt/local/lib/libidn.so.11
Reading symbols from /opt/local/lib/libintl.so.3...done.
Loaded symbols for /opt/local/lib/libintl.so.3
Reading symbols from /lib/libc.so.1...done.
Loaded symbols for /lib/libc.so.1
Reading symbols from /opt/local/lib/libssh2.so.1...done.
Loaded symbols for /opt/local/lib/libssh2.so.1
Reading symbols from /opt/local/lib/libssl.so.0.9.8...done.
Loaded symbols for /opt/local/lib/libssl.so.0.9.8
Reading symbols from /opt/local/lib/libcrypto.so.0.9.8...done.
Loaded symbols for /opt/local/lib/libcrypto.so.0.9.8
Reading symbols from /lib/libthread.so.1...
warning: Lowest section in /lib/libthread.so.1 is .dynamic at 00000074
done.
Loaded symbols for /lib/libthread.so.1
Reading symbols from /opt/local/lib/libxslt.so.1...done.
Loaded symbols for /opt/local/lib/libxslt.so.1
Reading symbols from /opt/local/lib/libxml2.so.2...done.
Loaded symbols for /opt/local/lib/libxml2.so.2
Reading symbols from /opt/local/lib/libz.so.1...done.
Loaded symbols for /opt/local/lib/libz.so.1
Reading symbols from /opt/local/lib/libiconv.so.2...done.
Loaded symbols for /opt/local/lib/libiconv.so.2
Reading symbols from /opt/gcc/lib/libgcc_s.so.1...done.
Loaded symbols for /opt/gcc/lib/libgcc_s.so.1
Reading symbols from /usr/lib/libm.so.1...done.
Loaded symbols for /usr/lib/libm.so.1
Reading symbols from /lib/libdl.so.1...
warning: Lowest section in /lib/libdl.so.1 is .dynamic at 00000074
done.
Loaded symbols for /lib/libdl.so.1
Reading symbols from /usr/lib/locale/en_US.ISO8859-1/en_US.ISO8859-1.so.3...done.
Loaded symbols for /usr/lib/locale/en_US.ISO8859-1/en_US.ISO8859-1.so.3
Reading symbols from /lib/ld.so.1...done.
Loaded symbols for /lib/ld.so.1
Core was generated by `./php -ef iconv.php'.
Program terminated with signal 11, Segmentation fault.
[New process 79440 ]
#0 0xec835356 in ?? ()
(gdb) bt full
#0 0xec835356 in ?? ()
No symbol table info available.
#1 0xfe5068ab in iconv () from /lib/libc.so.1
No symbol table info available.
#2 0x081f7a91 in php_iconv_string (in_p=0x889aab0 "Dave Kelsey", in_len=11, out=0x8046fc0, out_len=0x8046fc4, out_charset=0x889ab58 "ISO-8859-1",
in_charset=0x889ab48 "UTF-8") at /root/downloads/php/php-5.3.8/ext/iconv/iconv.c:501
cd = (libiconv_t) 0x8a12670
in_left = 11
out_size = 134508456
out_left = 43
out_p = 0x889ab88 "\200«\211\b\200«\211\bÔ×\210\b"
out_buf = 0x889ab88 "\200«\211\b\200«\211\bÔ×\210\b"
bsz = 43
result = 143239192
retval = PHP_ICONV_ERR_SUCCESS
#3 0x081faa54 in php_if_iconv (ht=3, return_value=0x889ab6c, return_value_ptr=0x0, this_ptr=0x0, return_value_used=1)
at /root/downloads/php/php-5.3.8/ext/iconv/iconv.c:2327
in_charset = 0x889ab48 "UTF-8"
out_charset = 0x889ab58 "ISO-8859-1"
in_buffer = 0x889aab0 "Dave Kelsey"
out_buffer = 0x0
out_len = 0
in_charset_len = 5
out_charset_len = 10
in_buffer_len = 11
err = 4261726858
#4 0x083991e6 in zend_do_fcall_common_helper_SPEC (execute_data=0x8a128a0) at /root/downloads/php/php-5.3.8/Zend/zend_vm_execute.h:320
opline = (zend_op *) 0x889a818
should_change_scope = 0 '\0'
#5 0x08398241 in execute (op_array=0x889a0a0) at /root/downloads/php/php-5.3.8/Zend/zend_vm_execute.h:107
ret = -33240438
execute_data = (zend_execute_data *) 0x8a128a0
nested = 1 '\001'
original_in_execution = 0 '\0'
#6 0x08377dc1 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /root/downloads/php/php-5.3.8/Zend/zend.c:1236
files = 0x8047164 ""
i = 1
file_handle = (zend_file_handle *) 0x8047c34
orig_op_array = (zend_op_array *) 0x0
orig_retval_ptr_ptr = (zval **) 0x0
#7 0x08328d93 in php_execute_script (primary_file=0x8047c34) at /root/downloads/php/php-5.3.8/main/main.c:2284
__orig_bailout = (sigjmp_buf *) 0x8047a24
__bailout = {6, 0, 2, -28186266, 143236960, 2, 124026880, 10485760, 0, 451, 144637952, -27328437, 134479947, 134511140, 143169632, 134510648,
134508896, 142788536, 0, 0, 134509984, 0, 0, 137530443, 67, 0, 134508896, 134479947, -27314224, 143236784, 134510136, 137625212, 134510176, -27873851, 0,
142788536, -27314224, 142480623, 134510392, 137358624, -27314224, 142484396, 134510224, 142480623, 134510336, -16797368, -16797380, 212116, 17,
143236012, 3, -16795644, 134510224, 4, -27314224, 137728298, 0, 2, 143185368, 142788536, 79691777, 0, 0, -28264130, -1451536758, -27328512, -27298104,
-28267682, -27324200, 0, 0, -27873640, 32, -27328512, 134510344, -27895262, -27324200, 0, 1319653082, -27895702, 143448376, -27328512, 134510344,
-34002432, -27324200, 0, -27298104, 7, 144748440, -27328512, 134510376, -28267395, -27324200, -27328512, 134510424, -28267454, 143448376, 7, 143448376,
137898921, 144748440, 134510544, 32, 7, -1043831655, 145041656, 1177, 142788536, 0, 7, 134510504, 137728298, 143448376, 144739664, 7, 134510544, 32, 0,
2, 0, 144739664, 142542513, 6, 7, 0, 144739664, 143185368, 142788536}
prepend_file_p = (zend_file_handle *) 0x0
append_file_p = (zend_file_handle *) 0x0
prepend_file = {type = ZEND_HANDLE_FILENAME, filename = 0x0, opened_path = 0x0, handle = {fd = 0, fp = 0x0, stream = {handle = 0x0, isatty = 0,
mmap = {len = 0, pos = 0, map = 0x0, buf = 0x0, old_handle = 0x0, old_closer = 0}, reader = 0, fsizer = 0, closer = 0}}, free_filename = 0 '\0'}
append_file = {type = ZEND_HANDLE_FILENAME, filename = 0x0, opened_path = 0x0, handle = {fd = 0, fp = 0x0, stream = {handle = 0x0, isatty = 0,
mmap = {len = 0, pos = 0, map = 0x0, buf = 0x0, old_handle = 0x0, old_closer = 0}, reader = 0, fsizer = 0, closer = 0}}, free_filename = 0 '\0'}
old_cwd_fd = -1
retval = 0
#8 0x083fbd48 in main (argc=3, argv=0x8047cc4) at /root/downloads/php/php-5.3.8/sapi/cli/php_cli.c:1184
__bailout = {6, 0, 134959818, 134955032, 134511236, -16997478, 124026880, 10485760, 0, 142737859, 134479872, -17039285, -17235893, 43096, -1,
134511772, 134510656, 142788536, 143169632, 143194129, 134511140, 0, 0, 138391421, 67, 0, 134510656, -65461, 134511312, 134511572, 134511576, 16, 0,
134511336, -27873640, -27310912, -27328512, 134511352, -27895262, -27310912, 0, 134511620, -27895702, 134959818, -17234952, -33423080, -34002432,
81189587, 3515, 134729512, -27873640, -27310912, -27328512, 134511416, -27873851, -34002432, 0, 134511432, -27874005, 134511616, 6401, 134511496, 3,
134511616, 134511572, 134511576, -16797368, -16797380, -16795644, 134511448, -16987850, 3, -16795644, 134511464, -16987912, 3, -16795644, 134511496,
-16953738, 3, -16795644, 134511496, -16954035, 3, 134511508, -16987912, 0, -16796876, -16795644, 134511688, -16920736, -16797368, 0, 2, 0, 142788576, 0,
0, 40, -16795644, 134959818, -33881832, -33550900, -33516788, 2, 135072476, 1, 0, -27873640, 1, -27328512, 134511648, -27896958, -33443444, 0, 0,
-27873640, 1, -27328512, 134511680, -27895262, -33443444, 0, 81189587, -27895702, 143081348, -33443992, 134511680}
exit_status = 0
c = 134512039
file_handle = {type = ZEND_HANDLE_MAPPED, filename = 0x8047da6 "iconv.php", opened_path = 0x0, handle = {fd = 143237716, fp = 0x889a254, stream = {
handle = 0x889a254, isatty = 0, mmap = {len = 202, pos = 0, map = 0xfdf30000, buf = 0xfdf30000 <Address 0xfdf30000 out of bounds>,
old_handle = 0xfe5f37e0, old_closer = 0x8389b7c <zend_stream_stdio_closer>}, reader = 0x8389b50 <zend_stream_stdio_reader>,
fsizer = 0x8389bb0 <zend_stream_stdio_fsizer>, closer = 0x8389c14 <zend_stream_mmap_closer>}}, free_filename = 0 '\0'}
behavior = 1
reflection_what = 0x0
orig_optind = 1
orig_optarg = 0x0
arg_free = 0x8047da6 "iconv.php"
arg_excp = (char **) 0x87ede1e
script_file = 0x8047da6 "iconv.php"
interactive = 0
module_started = 1
request_started = 1
lineno = 1
exec_direct = 0x0
exec_run = 0x0
exec_begin = 0x0
exec_end = 0x0
param_error = 0x0
hide_argv = 0
ini_entries_len = 110
(gdb)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 00:00:02 2025 UTC |
Whether I use $text = utf8_encode("Dave Kelsey"); or not makes no differenceAccording to ldd libiconv is loaded /usr/local/lib/libiconv.so.2 The backtrace also shows it's loading. I've followed what you suggested: ./configure '--prefix=/opt/bstage/php5.3.8' \ '--with-apxs2=/opt/bstage/apache2.2.21-php/bin/apxs' \ --disable-all \ '--with-iconv-dir=/opt/local' \ '--with-iconv' ldd shows it's loaded. When I run the script it fails. I've been debugging the script with gdb and it seems like it's the first time it calls iconv it fails though it also looks like gdb jumps all over the place. Breakpoint 1, php_iconv_string (in_p=0x8337fa4 "Dave Kelsey", in_len=11, out=0x804700c, out_len=0x8047010, out_charset=0x833803c "ISO-8859-1", in_charset=0x8339614 "UTF-8") at /root/downloads/php/php-5.3.8/ext/iconv/iconv.c:482 482 *out = NULL; (gdb) s 483 *out_len = 0; (gdb) s 482 *out = NULL; (gdb) s 480 php_iconv_err_t retval = PHP_ICONV_ERR_SUCCESS; (gdb) s 483 *out_len = 0; (gdb) s 485 cd = iconv_open(out_charset, in_charset); (gdb) s 409 { (gdb) s 485 cd = iconv_open(out_charset, in_charset); (gdb) s 487 if (cd == (iconv_t)(-1)) { (gdb) s 494 in_left= in_len; (gdb) s 495 out_left = in_len + 32; /* Avoid realloc() most cases */ (gdb) s 497 bsz = out_left; (gdb) s 498 out_buf = (char *) emalloc(bsz+1); (gdb) n 499 out_p = out_buf; (gdb) s 518 break; (gdb) s 502 while (in_left > 0) { (gdb) s 518 break; (gdb) s 501 int i = 1; (gdb) s 518 break; (gdb) s 503 result = iconv(cd, (char **) &in_p, &in_left, (char **) &out_p, &out_left); (gdb) print result $36 = 137530664 (gdb) print cd $37 = (libiconv_t) 0x84571b8 (gdb) print in_p $38 = 0x8337fa4 "Dave Kelsey" (gdb) print in_left $39 = 11 (gdb) print out_p $40 = 0x8338750 "H\2073\bH\2073\b\214º2\b" (gdb) print out_left $41 = 43 (gdb) s Breakpoint 2, 0xfec90a01 in iconv () from /lib/libc.so.1 (gdb) bt full #0 0xfec90a01 in iconv () from /lib/libc.so.1 No symbol table info available. #1 0x080c60c5 in php_iconv_string (in_p=0x8337fa4 "Dave Kelsey", in_len=11, out=0x804700c, out_len=0x8047010, out_charset=0x833803c "ISO-8859-1", in_charset=0x8339614 "UTF-8") at /root/downloads/php/php-5.3.8/ext/iconv/iconv.c:503 cd = (libiconv_t) 0x84571b8 in_left = 11 out_size = 134508504 out_left = 43 out_p = 0x8338750 "H\2073\bH\2073\b\214º2\b" out_buf = 0x8338750 "H\2073\bH\2073\b\214º2\b" bsz = 43 result = 137530664 retval = PHP_ICONV_ERR_SUCCESS i = 1 #2 0x080c9170 in php_if_iconv (ht=3, return_value=0x8338050, return_value_ptr=0x0, this_ptr=0x0, return_value_used=1, tsrm_ls=0x8328d28) at /root/downloads/php/php-5.3.8/ext/iconv/iconv.c:2330 in_charset = 0x8339614 "UTF-8" out_charset = 0x833803c "ISO-8859-1" in_buffer = 0x8337fa4 "Dave Kelsey" out_buffer = 0x0 out_len = 0 in_charset_len = 5 out_charset_len = 10 in_buffer_len = 11 err = 134508512 #3 0x081e6f09 in zend_do_fcall_common_helper_SPEC (execute_data=0x84591e8, tsrm_ls=0x8328d28) at /root/downloads/php/php-5.3.8/Zend/zend_vm_execute.h:320 opline = (zend_op *) 0x8338580 should_change_scope = 0 '\0' #4 0x081e5c71 in execute (op_array=0x8337ee4, tsrm_ls=0x8328d28) at /root/downloads/php/php-5.3.8/Zend/zend_vm_execute.h:107 ret = 134508512 execute_data = (zend_execute_data *) 0x84591e8 nested = 1 '\001' original_in_execution = 0 '\0' #5 0x081c3333 in zend_execute_scripts (type=8, tsrm_ls=0x8328d28, retval=0x0, file_count=3) at /root/downloads/php/php-5.3.8/Zend/zend.c:1236 files = 0x80471d8 "" i = 1 file_handle = (zend_file_handle *) 0x8337ee4 orig_op_array = (zend_op_array *) 0x0 orig_retval_ptr_ptr = (zval **) 0x0 #6 0x0816cb57 in php_execute_script (primary_file=0x8047ca4, tsrm_ls=0x8328d28) at /root/downloads/php/php-5.3.8/main/main.c:2284 __orig_bailout = (sigjmp_buf *) 0x8047a94 __bailout = {6, 0, 16, 0, 2, 134510192, 124026880, 10485760, 0, 451, 1638400, 67, 67, 134511252, 137528184, 134510760, 134509008, 137277272, 134510096, 137530664, 137807256, 0, 0, 135711186, 59, 0, 134509008, 67, -16786280, -16795624, 0, 137277272, 134510320, -19784664, 134510488, 135619122, -19784664, 137152012, 137530664, -19784664, 2, 166920448, 2002, 135686137, 17, 0, 138530064, -19974830, 137591240, 137277272, -19784664, 135925002, 0, 2, 137541776, 135686137, 76021761, 0, 0, 0, 318572, ---Type <return> to continue, or q <return> to quit--- Questions: There is no iconv funtion in libc.so, I think that's the library that gets the process running and has nothing to do with the problem. Is this correct? When I look in libiconv.so.2 with elfdump I don't see a iconv function but I do see libicnov. Does the function name get mangled? ... looks like in ext/iconv/iconv.c there is a #define that changes iconv to libiconv though it seems to crash on the first call, however looking at the values on other runs, it seemed like the value of in_left and out_left never changed. I'd like to know what's going on.I solved the issue. The steps I followed: create a config script called doit_php.vBulletin (build php for vBulletin) ./configure '--prefix=/opt/bstage/php5.3.8' \ '--with-apxs2=/opt/bstage/apache2.2.21-php/bin/apxs' \ --disable-all \ '--with-iconv-dir=/opt/local' \ '--with-iconv' rm config.cache && . doit_php.vBulletin && make clean && make got this working. verified with at simple test: iconv.php : <?php $text = "Dave Kelsey"; $string = "L<f6>ic & Ren<e9>"; $output = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $string); echo 'Original : ', $text, PHP_EOL; echo 'Plain : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL; echo 'nother : ', $string, PHP_EOL; echo 'nother2 : ', $output, PHP_EOL; ?> ./sapi/cli/php -ef iconv.php Original : Dave Kelsey Plain : Dave Kelsey nother : Löic & René nother2 : iconv2.php: <?php $text = "Dave Kelsey"; $string = "Löic & René"; $output = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $string); echo 'Original : ', $text, PHP_EOL; echo 'Plain : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL; echo 'nother : ', $string, PHP_EOL; echo 'nother2 : ', $output, PHP_EOL; ?> ./sapi/cli/php -ef iconv2.php Original : Dave Kelsey Plain : Dave Kelsey nother : Löic & René nother2 : Löic & René Once I got php running only with my compiled iconv in /opt/local I gradually added modules until I got everything working. I found the any xml modules used the old iconv lib. misc extensions were being compiled build with #include <iconv.h> I renamed the /usr/include/iconv.h so that it would not be found and I set the CFLAGS, LDFLAGS and LIBS in my configure helper script as follows: CFLAGS='-I/opt/local/inclue' LDFLAGS='-L/opt/local/lib -L/opt/mysql-5.5.8-solaris10-i386/lib -R/opt/local/lib -R/opt/mysql-5.5.8-solaris10-i386/lib' LIBS='-liconv' export CFLAGS LDFLAGS LIBS my full configure helper script is now: CFLAGS='-I/opt/local/inclue' LDFLAGS='-L/opt/local/lib -L/opt/mysql-5.5.8-solaris10-i386/lib -R/opt/local/lib -R/opt/mysql-5.5.8-solaris10-i386/lib' LIBS='-liconv' export CFLAGS LDFLAGS LIBS ./configure '--prefix=/opt/bstage/php5.3.8' \ '--with-apxs2=/opt/bstage/apache2.2.21-php/bin/apxs' \ --disable-all \ '--with-iconv-dir=/opt/local' \ '--with-iconv' \ '--enable-bcmath' \ '--enable-mbstring' \ '--with-zlib' \ '--with-config-file-path=/opt/bstage/php5.3.8/lib' \ '--enable-dom' \ '--with-xsl' \ '--enable-libxml' \ '--with-libxml-dir=/opt/local' \ '--with-regex=system' \ '--without-sqlite' \ '--mandir=/opt/local/man' \ '--with-mysql=/opt/mysql-5.5.8-solaris10-i386' \ '--with-mysqli=/opt/mysql-5.5.8-solaris10-i386/bin/mysql_config' \ '--with-curl=/opt/local' \ '--with-xmlrpc' \ '--enable-json' \ '--enable-hash' \ '--enable-session' \ '--enable-xml' I didn't find any helpful documentation stating that if using a different iconv lib, that's not in the standard location, set CFLAGS, LIBS and LDFLAGS appropriately. I also found that with mysql and mysqli, the linker was always looking in /usr/sfw/lib though I specified on the configure /opt/mysql-5.5.8-solaris10-i386. Every time I remade the Makefile I had to edit it moving the -L and -R reference to /usr/sfw/lib to after /opt/mysql-5.5.8-solaris10-i386 so that the correct mysqlclient lib was linked to.