Re: clarification on maximum string sizes in PHP on 64 bit linux

From: Date: Thu, 19 Nov 2009 22:52:26 +0000
Subject: Re: clarification on maximum string sizes in PHP on 64 bit linux
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-46115@lists.php.net to get a copy of this message
> Code: > <?php > $s = str_repeat('A', pow(2,30)); > $t = $s.str_repeat('B', pow(2,30));; // fails with segfault > printf("strlen: %u last-char: %s", strlen($s), substr($s, pow(2,30)-1)); > ?> > --- > Result: > ./sapi/cli/php -d memory_limit=-1 a2.php > > Fatal error: Out of memory (allocated 2148270080) (tried to allocate > 18446744071562067969 bytes) in /home/matt/tmp/php-src-5.2/a2.php on > line 3 > ---- hmmm, 18446744071562067969 is 0xFFFFFFFF80000001 it seems a 32bit variable was used somewhere in the calculations and was assigned to a 64bit signed int. what particular version of php did you use? Did you try 5.3.1RC4? 5.2.12RC1? I'd try myself if I had 4GB of RAM. -jv

« previous php.internals (#46115) next »