ID: 15799 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Analyzed +Status: Closed Bug Type: ICONV related Operating System: Linux PHP Version: 4.0CVS-2002-02-2 New Comment:
Fixed in CVS and 4.2.0 branch. Previous Comments: ------------------------------------------------------------------------ [2002-03-09 15:34:13] [EMAIL PROTECTED] I've sent a patch to jan (wouldn't make sense to paste here as long lines get broken) and I'm pretty sure it's the right fix. I bet the current code never really worked the way it was written. Anyway I'm for deprecating iconv_(set|get)_encoding. All it does is changing INI settigns which can be easily read and set with ini_get("iconv.input_encoding") or ini_set(). However I don't know what the general consesus in in such situations. The two functions just seem redundant to me. ------------------------------------------------------------------------ [2002-03-09 11:19:45] [EMAIL PROTECTED] The segfaults still happen even after the recent changes in the iconv extension and the output buffering code. Here is a small script to reproduce it. Method 1 (commented out) works fine, method 2 segfaults. <? error_reporting(E_ALL); $text = <<< END Thanks !! David Chang ----------------------------------------------------------------- < ¨C¤Ñ³£ Yahoo!©_¼¯ > www.yahoo.com.tw END; // Method 1: Works! /* $src = 'BIG5'; $dst = 'UTF-8'; $rc = iconv($src, $dst, $text); header('Content-Type: text/plain; charset=UTF-8'); echo $rc; */ // Method 2: Segfaults! iconv_set_encoding('input_encoding', 'BIG5'); iconv_set_encoding('internal_encoding', 'UTF-8'); iconv_set_encoding('output_encoding', 'UTF-8'); ob_start('ob_iconv_handler'); echo $text; $rc = ob_get_contents(); ob_end_clean(); header('Content-Type: text/plain; charset=UTF-8'); echo $rc; ?> Since the line numbers changed since my initial report and I use a different script (above), here's also an updated bt: Program received signal SIGSEGV, Segmentation fault. 0x4010621a in chunk_free (ar_ptr=0x7a62e850, p=0x404ea168) at malloc.c:3049 3049 malloc.c: No such file or directory. (gdb) bt #0 0x4010621a in chunk_free (ar_ptr=0x7a62e850, p=0x404ea168) at malloc.c:3049 #1 0x401061bf in free () at malloc.c:2952 #2 0x403744ec in zif_iconv_set_encoding () at iconv.c:267 #3 0x40317077 in execute () at ./zend_execute.c:959 #4 0x40328fb4 in zend_execute_scripts () at zend.c:373 #5 0x4033cea7 in php_execute_script () at main.c:1309 #6 0x40337240 in apache_php_module_main () at sapi_apache.c:100 #7 0x403381d8 in send_php (r=0x81825a0, display_source_mode=0, filename=0x81841a8 "/usr/local/httpd/htdocs/headhorde/iconv.php") at mod_php4.c:575 #8 0x40338263 in send_parsed_php (r=0x81825a0) at mod_php4.c:590 #9 0x8055250 in ap_invoke_handler () #10 0x80677bc in ap_some_auth_required () #11 0x8067833 in ap_process_request () #12 0x805fd27 in ap_child_terminate () #13 0x805fed5 in ap_child_terminate () #14 0x8060016 in ap_child_terminate () #15 0x8060628 in ap_child_terminate () #16 0x8060e95 in main () #17 0x400cca8e in __libc_start_main () at ../sysdeps/generic/libc-start.c:93 ------------------------------------------------------------------------ [2002-02-28 20:26:43] [EMAIL PROTECTED] Better yet. Could you make a script that included base64/uuencoded BIG5 data end decode it and feed it to iconv? ------------------------------------------------------------------------ [2002-02-28 19:32:59] [EMAIL PROTECTED] BIG5.... I guess it's supported by libiconv and your glibc is ok.. If text is small enough, could you pate uuencoded text there? ------------------------------------------------------------------------ [2002-02-28 19:21:20] [EMAIL PROTECTED] Hi, it's me again. I got another segfault, this time with the iconv output buffer handler, though iconv() seems to work now, somehow. That's the code: iconv_set_encoding('input_encoding', 'BIG5'); iconv_set_encoding('internal_encoding', 'UTF-8'); iconv_set_encoding('output_encoding', 'UTF-8'); ob_start('ob_iconv_handler'); echo $text; $return = ob_get_contents(); ob_end_clean(); $text contains a BIG5 encoded message of course. This is the bt: Program received signal SIGSEGV, Segmentation fault. 0x4010621a in chunk_free (ar_ptr=0x89fff7cb, p=0x404e8108) at malloc.c:3049 3049 malloc.c: No such file or directory. (gdb) (gdb) bt #0 0x4010621a in chunk_free (ar_ptr=0x89fff7cb, p=0x404e8108) at malloc.c:3049 #1 0x401061bf in free () at malloc.c:2952 #2 0x40372aac in zif_iconv_set_encoding () at iconv.c:174 #3 0x40316987 in execute () at ./zend_execute.c:959 #4 0x40316baf in execute () at ./zend_execute.c:959 #5 0x403288c4 in zend_execute_scripts () at zend.c:373 #6 0x4033c507 in php_execute_script () at main.c:1265 #7 0x40336b40 in apache_php_module_main () at sapi_apache.c:100 #8 0x40337ad8 in send_php (r=0x81823a0, display_source_mode=0, filename=0x81841b0 "/usr/local/httpd/htdocs/headhorde/imp/view.php") at mod_php4.c:575 #9 0x40337b63 in send_parsed_php (r=0x81823a0) at mod_php4.c:590 #10 0x8055250 in ap_invoke_handler () #11 0x80677bc in ap_some_auth_required () #12 0x8067833 in ap_process_request () #13 0x805fd27 in ap_child_terminate () #14 0x805fed5 in ap_child_terminate () #15 0x8060016 in ap_child_terminate () #16 0x8060628 in ap_child_terminate () #17 0x8060e95 in main () #18 0x400cca8e in __libc_start_main () at ../sysdeps/generic/libc-start.c:93 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15799&edit=1