Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100180 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75008 invoked from network); 11 Aug 2017 11:10:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2017 11:10:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=newaltgroup@bk.ru; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=newaltgroup@bk.ru; sender-id=pass Received-SPF: pass (pb1.pair.com: domain bk.ru designates 94.100.177.89 as permitted sender) X-PHP-List-Original-Sender: newaltgroup@bk.ru X-Host-Fingerprint: 94.100.177.89 smtp29.i.mail.ru Received: from [94.100.177.89] ([94.100.177.89:39632] helo=smtp29.i.mail.ru) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/E4-34801-6B09D895 for ; Fri, 11 Aug 2017 07:10:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bk.ru; s=mail; h=To:Date:Message-Id:Subject:Mime-Version:Content-Type:From; bh=MFoJhEs6duhZzZKeRniLcJAOg1mkBPjqOt/00H8g46A=; b=nomcXnfnDo41p/fkKkAScp65N10POOA7F/+W1yvAs3NCDDsN44M1a9A2YfIoa6DN8zHfJpgbLjalyZKghj+jXtOe8QtullMgN4zkkW2So33Xk4B/Rqsj7CY8YM4ZAagQmwteyxNTgHKa3C1KOE7E4xGCrz6bQgg8FyPZ+Z7gK9Q=; Received: by smtp29.i.mail.ru with esmtpa (envelope-from ) id 1dg7pz-0002fS-8w for internals@lists.php.net; Fri, 11 Aug 2017 14:10:43 +0300 Content-Type: multipart/alternative; boundary="Apple-Mail=_8CDB756B-C96F-4BB6-8963-69152AFC1EF7" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Message-ID: Date: Fri, 11 Aug 2017 14:10:47 +0300 To: internals@lists.php.net X-Mailer: Apple Mail (2.3273) Authentication-Results: smtp29.i.mail.ru; auth=pass smtp.auth=newaltgroup@bk.ru smtp.mailfrom=newaltgroup@bk.ru X-7FA49CB5: 0D63561A33F958A5D9E039E843D4B10A3BCBFB3952B618F055ABB68FF2666F34725E5C173C3A84C363D77626233CE5ABF4AC852911688AE3D2D576BCF940C736C4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F05F538519369F3743B503F486389A921A5CC5B56E945C8DA X-Mailru-Sender: 5359E0D685F10627A37960CE49917681168B77CF2814E65674AE369901B5655BEA62DA57F118970E18C1F6AB3FBD83F13DDE9B364B0DF289B1C9E140B68917A5027D9DD7AE851095AE208404248635DF X-Mras: OK Subject: [Request][Discussion] Double value as array key improvement From: newaltgroup@bk.ru (Andrew Nester) --Apple-Mail=_8CDB756B-C96F-4BB6-8963-69152AFC1EF7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hello everyone! I was working on following request https://bugs.php.net/bug.php?id=3D75053= which resulted in following = pull request https://github.com/php/php-src/pull/2676 = The problem here is following: when we=E2=80=99re using large numbers as = array index when adding new elements it could overwrite already existing = value. Assume we have 2 indexes 5076964154930102272 and = 999999999999999999999999999999 with different value set for them. Because 999999999999999999999999999999 is larger than maximum long int = number for 64-bit systems, it will be converted to double. = (corresponding code here = https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1= 648 = ) But when double value is used as array indexes, it is converted to long = integer. (f.e., code is here = https://github.com/php/php-src/blob/master/Zend/zend_execute.c#L1573 = ) At this case it causes overflow and we=E2=80=99ve got index equal to = 5076964154930102272 and as a result - we=E2=80=99re overwriting = previously set value. My suggestion is following: 1) when double key is less than maximum possible long integer - convert = it to integer 2) if it=E2=80=99s larger - convert it to string. That=E2=80=99s what implemented in proposed PR. Another possible option is just to throw warning in this case (proposed = by Nikita Popov) I would happy to hear any feedback and suggestions about this solution. Thanks!= --Apple-Mail=_8CDB756B-C96F-4BB6-8963-69152AFC1EF7--