From: asari at users dot sourceforge dot net Operating system: Linux PHP version: 5.3CVS-2009-03-13 (snap) PHP Bug Type: JSON related Bug description: json_decode fails to decode large int inside an array
Description: ------------ In some cases, json_decode() fails to decode large integer (over 10000000000000000) inside an array, e.g. "[10000000000000001]". $ uname -a Linux _HOSTNAME_.localdomain 2.6.18-53.1.21.el5 #1 SMP Tue May 20 09:35:07 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux $ lsb_release -a LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch Distributor ID: CentOS Description: CentOS release 5.2 (Final) Release: 5.2 Codename: Final $ ./sapi/cli/php --version PHP 5.3.0beta2-dev (cli) (built: Mar 13 2009 21:55:38) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies $ cat config.nice #! /bin/sh # # Created by configure './configure' \ '--prefix=/tmp/php53' \ "$@" Reproduce code: --------------- $ for ((i=10000000000000000; i<10000000000000006; i++)); do echo $i; ./sapi/cli/php -r 'var_dump(json_decode("['$i']"));'; echo; done Expected result: ---------------- 10000000000000000 array(1) { [0]=> int(10000000000000000) } 10000000000000001 array(1) { [0]=> int(10000000000000001) } 10000000000000002 array(1) { [0]=> int(10000000000000002) } 10000000000000003 array(1) { [0]=> int(10000000000000003) } 10000000000000004 array(1) { [0]=> int(10000000000000004) } 10000000000000005 array(1) { [0]=> int(10000000000000005) } Actual result: -------------- 10000000000000000 array(1) { [0]=> int(10000000000000000) } 10000000000000001 array(1) { [0]=> int(10000000000000000) } 10000000000000002 array(1) { [0]=> int(10000000000000002) } 10000000000000003 array(1) { [0]=> int(10000000000000004) } 10000000000000004 array(1) { [0]=> int(10000000000000004) } 10000000000000005 array(1) { [0]=> int(10000000000000004) } -- Edit bug report at http://bugs.php.net/?id=47644&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47644&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47644&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47644&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47644&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47644&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47644&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47644&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47644&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47644&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47644&r=support Expected behavior: http://bugs.php.net/fix.php?id=47644&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47644&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47644&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47644&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47644&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47644&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47644&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47644&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47644&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47644&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47644&r=mysqlcfg