ID: 32738 Updated by: [EMAIL PROTECTED] Reported By: pvandijk at gmail dot com -Status: Open +Status: Bogus Bug Type: Reproducible crash Operating System: Linux 2.4.22-1.2115.nptl PHP Version: 4.3.11 New Comment:
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. This is because we have a 2 byte refcount counter. You're adding too many (internal) references to $data overflowing the counter. When it hits zero the data is free and you can't access it anymore - resulting in the segfault. Previous Comments: ------------------------------------------------------------------------ [2005-04-18 02:50:16] pvandijk at gmail dot com Description: ------------ Hashes with a large number of keys and large key data size seem to cause memory corruption, which in turn causes php to either segfault or hang upon exiting (depending on the context of the code). I've heard mention that arrays are not unlimited in size. This issue seems to occur at about 65535 elements in my tests, but also depends on the size of the keys. Presumably this is because i'm indexing my arrays with Strings, and therefore it's running out of memory faster. If the memory limit of a hash is reached, should it not be handled more gracefully than corrupting memory, which results in a segfault? The code example i've provided seems to reproduce a crash under both linux and windows, php 4.3.11 Reproduce code: --------------- <?php $data = 'hello, i like cheese'; $ar = array(); for($i = 1000000; $i < 3000000 ; $i++) { $key = 'abc'.$i; $ar[$key] = $data; } function check($ar) { global $data; foreach($ar as $k => $value) { if($data != $value) { print 'invalid value: '. $k .' => '. $value ."\r\n"; } } } check($ar); print 'done.'."\r\n"; ?> Expected result: ---------------- done. Actual result: -------------- "done. Segmentation fault" sorry i cant provide a backtrace or any further info, i dont have access to these tools on my current dev server. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32738&edit=1