PHP 4.0 Bug #2690: repeated operations on a character array (string) cause php to segfault

From: Date: Tue, 09 Nov 1999 19:59:32 +0000
Subject: PHP 4.0 Bug #2690: repeated operations on a character array (string) cause php to segfault
Groups: php.dev 
Request: Send a blank email to php-dev+get-12247@lists.php.net to get a copy of this message
From: jmat@firewind.net Operating system: Linux PHP version: 4.0 Latest CVS (09/11/1999) PHP Bug Type: Reproduceable crash Bug description: repeated operations on a character array (string) cause php to segfault I upgraded my 11/01/99 CVS build with the RC4 build (totally starting over from scratch), and started having some very strange problems when I started manipulating strings. Basically I have a string that is used for 'flags', (i.e. position 1 has a flag of A, position 2 B, etc.). Normally, I change these flags from a webpage by recursing through an array and changing individual characters.... but suddenly it stopped working, and has started segmentation faulting ... here's a code segment of the problem code: $inarray = array(1=>"A",2=>"B",3=>"C"); // etc... $string = "A--DF--S--DS---C"; while (list($key,$val) = each($inarray)) { echo "PRE: $string<br>"; $string[$key] = $val; echo "POST: $string<p>"; } ... this works for about 2 iterations, then we have major memory munging, and $string turns into a bunch of garbage.. (even a Yen symbol or three) after 2 more iterations, the Apache child process dies. I tried doing a few different things, including converting $string to an array first, then doing a individual element replace... but then I discovered that a reset($inarray) also segfaulted things.

« previous php.dev (#12247) next »