#39576 [NEW]: Segfault on array_intersect

From: Date: Wed, 22 Nov 2006 00:26:43 +0000
Subject: #39576 [NEW]: Segfault on array_intersect
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-105275@lists.php.net to get a copy of this message
From: php at seven dot net dot nz Operating system: Linux PHP version: 5.2.0 PHP Bug Type: Reproducible crash Bug description: Segfault on array_intersect Description: ------------ When intersecting 2 arrays, PHP segfaults. The first array is the contents of get_object_vars ($this), the second is a key => object pair. This does not reproduce the bug, but this is what the code looks like. Setting up the environment to reproduce it will take some time (objects returned by a database etc), so I'll only do it if necessary Reproduce code: --------------- <?php class Test { function run () { $c = array_intersect_key ( get_object_vars ($this), $this->columns ); print_r ($c); } } class Test2 {} $test = new Test; $test->columns = array ('id' => new Test2); $test->id = '1'; $test->run (); ?> Expected result: ---------------- Array ( [id] => 1 ) Actual result: -------------- Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1215007056 (LWP 21112)] 0xb765ab06 in zend_hash_del_key_or_index (ht=0xb6c47e44, arKey=0xb6c7e828 "", nKeyLength=1, h=3445614760, flag=0) at /root/php-5.2.0/Zend/zend_hash.c:462 462 p = ht->arBuckets[nIndex]; (gdb) bt #0 0xb765ab06 in zend_hash_del_key_or_index (ht=0xb6c47e44, arKey=0xb6c7e828 "", nKeyLength=1, h=3445614760, flag=0) at /root/php-5.2.0/Zend/zend_hash.c:462 #1 0xb759b96c in php_array_intersect (ht=2, return_value=0xb6c7ee74, return_value_ptr=<value optimized out>, this_ptr=0x0, return_value_used=1, behavior=<value optimized out>, data_compare_type=0, key_compare_type=0) at /root/php-5.2.0/ext/standard/array.c:3135 #2 0xb766b6b3 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfd50820) at /root/php-5.2.0/Zend/zend_vm_execute.h:200 #3 0xb76697cb in execute (op_array=0xb6c56bec) at /root/php-5.2.0/Zend/zend_vm_execute.h:92 #4 0xb766b236 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfd509a0) at /root/php-5.2.0/Zend/zend_vm_execute.h:234 #5 0xb76697cb in execute (op_array=0xb6c1a474) at /root/php-5.2.0/Zend/zend_vm_execute.h:92 #6 0xb766b236 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfd50ed0) at /root/php-5.2.0/Zend/zend_vm_execute.h:234 #7 0xb76697cb in execute (op_array=0xb6c8144c) at /root/php-5.2.0/Zend/zend_vm_execute.h:92 #8 0xb766ecdd in ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER (execute_data=0xbfd527a0) at /root/php-5.2.0/Zend/zend_vm_execute.h:4572 #9 0xb76697cb in execute (op_array=0xb6c71574) at /root/php-5.2.0/Zend/zend_vm_execute.h:92 #10 0xb76510af in zend_execute_scripts (type=8, retval=0x80, file_count=3) at /root/php-5.2.0/Zend/zend.c:1097 #11 0xb7615afa in php_execute_script (primary_file=0xbfd54ac8) at /root/php-5.2.0/main/main.c:1758 #12 0xb76d2711 in php_handler (r=0x84ab238) at /root/php-5.2.0/sapi/apache2handler/sapi_apache2.c:592 #13 0x08078709 in ap_run_handler () #14 0x0807b8b1 in ap_invoke_handler () #15 0x0806a42c in ap_internal_redirect () #16 0xb79433c5 in ?? () from /usr/lib/apache2/modules/mod_rewrite.so #17 0x084ab228 in ?? () #18 0x084a2978 in ?? () #19 0xb7944da7 in ?? () from /usr/lib/apache2/modules/mod_rewrite.so #20 0x084a36c8 in ?? () #21 0x00000000 in ?? () -- Edit bug report at http://bugs.php.net/?id=39576&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39576&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39576&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39576&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39576&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39576&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39576&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39576&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39576&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39576&r=support Expected behavior: http://bugs.php.net/fix.php?id=39576&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39576&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39576&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39576&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39576&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39576&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39576&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39576&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39576&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39576&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39576&r=mysqlcfg

« previous php.bugs (#105275) next »