PHP hangs on 2.2250738585072011e-308

Support/Development for PHP
breun
Long Time Forum Regular
Long Time Forum Regular
Posts: 2813
Joined: Sat Aug 20, 2005 9:30 am
Location: The Netherlands

PHP hangs on 2.2250738585072011e-308

Unread post by breun »

Some PHP installations apparently hang when encountering the numeric value 2.2250738585072011e-308. It looks like this is a bug that only affects 32-bit versions of PHP.

Original discovery: http://www.exploringbinary.com/php-hang ... 2011e-308/
Analysis on Hacker News: http://news.ycombinator.com/item?id=2066084
PHP bug report: http://bugs.php.net/bug.php?id=53632
Lemonbit Internet Dedicated Server Management
User avatar
mikeshinn
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
Posts: 4149
Joined: Thu Feb 07, 2008 7:49 pm
Location: Chantilly, VA

Re: PHP hangs on 2.2250738585072011e-308

Unread post by mikeshinn »

So to add some more data points, looks like only 5.3.x 32 bit has this issue. 5.2.x does not appear to be effected. So far I can only reproduce this in PHP 5.3.x. Might happen in versions previous to 5.3.x, but so far 5.2.x seems to not have this issue.

[mshinn@ac2 ~]$ file /usr/bin/php
/usr/bin/php: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[mshinn@ac2 ~]$ php -v
PHP 5.2.16 (cli) (built: Dec 19 2010 11:27:08)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
[mshinn@ac2 ~]$ php -r "print 2.2250738585072011e-308;"
2.2250738585072E-308

$ file /usr/bin/php
/usr/bin/php: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped
$ php -v
PHP 5.3.3 (cli) (built: Jul 22 2010 15:37:02)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
$ php -r "print 2.2250738585072011e-308;"
Killed

So, to recap, only 32 bit builds of PHP 5.3.x are effected. This can only happen in practical cases if you had an application where a parameter is cast as a float, not as an int and it could take a parameter that big (so user inputs for example could trigger this). So the case is pretty rare.

So, this shouldnt effect anyone other than 32 bit users using 5.3.x PHP builds (which are not in stable, and for just this kind of reason).
scott
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
Posts: 8355
Joined: Wed Dec 31, 1969 8:00 pm
Location: earth
Contact:

Re: PHP hangs on 2.2250738585072011e-308

Unread post by scott »

I haven't been unable to duplicate this on i386 PHP 5.2.16. If you do experience this on 5.2.16 please post your test scripts and reports here.
breun
Long Time Forum Regular
Long Time Forum Regular
Posts: 2813
Joined: Sat Aug 20, 2005 9:30 am
Location: The Netherlands

Re: PHP hangs on 2.2250738585072011e-308

Unread post by breun »

Good to know ART builds aren't affected.

Interesting quote from the bug report's comments:
rasmus@php.net wrote:Guys, we already know the problem. We are hitting an annoying x87 FPU design flaw. You can read all about it here if you are interested:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323

And there is a good paper on it here:

http://hal.archives-ouvertes.fr/docs/00 ... rticle.pdf

We don't need any more compile reports. If you are on an architecture that uses the x87 FPU and you haven't forced SSE or float-store then you will see this problem.
Lemonbit Internet Dedicated Server Management
camaran
Forum User
Forum User
Posts: 34
Joined: Fri Aug 21, 2009 12:28 pm

Re: PHP hangs on 2.2250738585072011e-308

Unread post by camaran »

php 5.3.5 and php 5.2.17 area Released!
Post Reply