Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87897 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94358 invoked from network); 25 Aug 2015 07:28:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Aug 2015 07:28:52 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.171 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.213.171 mail-ig0-f171.google.com Received: from [209.85.213.171] ([209.85.213.171:38005] helo=mail-ig0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/30-24891-2391CD55 for ; Tue, 25 Aug 2015 03:28:50 -0400 Received: by igfj19 with SMTP id j19so5042334igf.1 for ; Tue, 25 Aug 2015 00:28:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=9C2mG2v0CXd2gCv2vHjTbrKNzcDKaWeAExX/wCitoRk=; b=Hrso+zWjfzIM8LMD2YLiW8q8zyQGDB3D4nYpWKntD1ljA81Ni4ZNBEidMTevVn0rH5 CJ9vFgD3lY3l6FFsAP/v6VIDHACeoiii9DkZWfxSS8sTfzQC2tAhVEixSTJypDExcpw7 haAtiAqRaRBZ3Ib7YPMlZIqnV/FNiZTGFkBi50aCtprZQ3AwFSixjocwl5QoX27kXd9m /cJ6kFCFHHzWaeiVGln3pajiC3kgT/A1tmRmNXB9Px+xbil1AnK/LKxrH/LAXMH9GCF7 dYPvNEB99vagDAmPbR6CTqbMhuZA7yTq3Vv1nIUDQJ+7EOSFel5QyJN0d52kzjz9bj2l eo6Q== X-Gm-Message-State: ALoCoQnozVXydiA4vt0PQBOHqF8zvGj/Q5s7y7D6eYWAOuAvQmVowJaHZpoh1z4iBtzSOybdsMgsOGQpSLAmpQ1rWB1eN0If7D1mrrAAf1BgED7+RjbOJzYm325xBtv/Rrdybhx/8tI/h1LGIZ9bsChsr22e34RhXp+GXjKa5wVm2nidpDUtF1E= MIME-Version: 1.0 X-Received: by 10.50.6.16 with SMTP id w16mr926312igw.74.1440487722837; Tue, 25 Aug 2015 00:28:42 -0700 (PDT) Received: by 10.50.25.169 with HTTP; Tue, 25 Aug 2015 00:28:42 -0700 (PDT) In-Reply-To: <00c101d0de77$4a809680$df81c380$@belski.net> References: <02a601d0dbed$2c828df0$8587a9d0$@belski.net> <02ae01d0dbf5$01c17330$05445990$@belski.net> <02b001d0dbf5$607ab7b0$21702710$@belski.net> <02ba01d0dbfb$3de2c390$b9a84ab0$@belski.net> <55DA4924.2060401@gmail.com> <00c101d0de77$4a809680$df81c380$@belski.net> Date: Tue, 25 Aug 2015 10:28:42 +0300 Message-ID: To: Anatol Belski Cc: Rowan Collins , PHP Internals Content-Type: multipart/alternative; boundary=047d7ba97972061212051e1dafc9 Subject: Re: [PHP-DEV] Overflow checks and integral vars comparison From: dmitry@zend.com (Dmitry Stogov) --047d7ba97972061212051e1dafc9 Content-Type: text/plain; charset=UTF-8 Hi Anatol, I don't see any problem adding ZEND_LONG_INT_OVF and similar macros into 7.0. Thanks. Dmitry. On Mon, Aug 24, 2015 at 5:15 PM, Anatol Belski wrote: > Hi Rowan, > > > -----Original Message----- > > From: Rowan Collins [mailto:rowan.collins@gmail.com] > > Sent: Monday, August 24, 2015 12:29 AM > > To: internals@lists.php.net > > Subject: Re: [PHP-DEV] Overflow checks and integral vars comparison > > > > On 22/08/2015 02:38, Sherif Ramadan wrote: > > > I see. So you're not actually doing overflow checks then? Because at > > > the point you'd be checking this zend_long or size_t it could have > > > already overflowed or wrapped. The subject may have misled me to > > > understand differently. > > > > I think I understand the confusion: you are thinking of overflow as > something > > which happens *within* a type based on some operation (addition, > > multiplication, etc). > > > > Anatol is talking about overflows which occur when casting *between* > > types: a value of 2^33 can safely be passed around as a 64-bit integer, > no > > overflow has occurred; but attempting to cast it to a 32-bit integer will > > immediately overflow the 32-bit integer. > > > > Since many PHP extensions are wrappers around libraries which may only > deal in > > 32-bit types, this cast is common, necessitating range checks like the > ones > > proposed. > > > Yep, that's the exact point. Not touching arithmetic operations as it is a > complex thing. Even on 64-bit fe there are intrinsics for doing 128-bit > math which could be used. ASM could be helpful ofc, however it needs much > care, fe even within GCC versions. So it is big and should be another story > :) > > Overflows in the cast can happen when passing args, comparing variables of > different type or signess, or even with the numeric constants. Hence that > cast (zend_long)INT_MAX for example. At the end - it's still an > overflow/underflow issue. I'm going for an RFC with this to target 7.1. > > Thanks. > > anatol > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --047d7ba97972061212051e1dafc9--