Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98808 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84456 invoked from network); 15 Apr 2017 19:13:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2017 19:13:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Received: from [82.113.146.227] ([82.113.146.227:49522] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/C1-61625-2D072F85 for ; Sat, 15 Apr 2017 15:13:24 -0400 Received: from [192.168.1.24] (static-84-9-22-15.vodafonexdsl.co.uk [84.9.22.15]) by xdebug.org (Postfix) with ESMTPSA id CEA7110C64B; Sat, 15 Apr 2017 20:13:19 +0100 (BST) Date: Sat, 15 Apr 2017 20:13:17 +0100 User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: Nikita Popov CC: PHP Developers Mailing List Message-ID: <797C79DF-B6A8-4012-8584-26CF816A1278@php.net> Subject: Re: Inconsistency in line numbers. From: derick@php.net (Derick Rethans) On April 15, 2017 5:24:53 PM GMT+01:00, Nikita Popov wrote: >On Sat, Apr 15, 2017 at 5:25 PM, Derick Rethans wrote: > >> Hi Nikita, >> >> Through Xdebug bug #1413 (https://bugs=2Exdebug=2Eorg/view=2Ephp?id=3D1= 413), >I >> noticed >> that behaviour with class constants changed between PHP 7=2E1=2E3 and P= HP >> 7=2E1=2E4=2E >> I *believe* it is because of the fix for issue #69676 >> (https://bugs=2Ephp=2Enet/bug=2Ephp?id=3D69676) that got fixed in PHP 7= =2E1=2E4=2E >> >> With OPcache loaded, the INIT_ARRAY and further opcodes are relisted >as >> being >> on line 15 instead of line 17=2E Although, I would probably argue that >> INIT_ARRAY should really be on line 13 (the opening [)=2E >> >> Without OPcache loaded, in PHP 7=2E1=2E3, FETCH_CLASS_CONSTANT is on li= ne >15, >> and >> the INIT_ARRAY and further opcodes are on line 17=2E In PHP 7=2E1=2E4, = they >are >> all >> on line 15 - with 17 no longer showing up=2E >> >> I believe, the behaviour with and without OPcache should be the same, >and I >> would argue that the correct result would need to be that >> FETCH_CLASS_CONSTANT >> (if still present, OPcache optimises it out) should be on line 15, >the >> INIT_ARRAY on line 13, and the SEND_VAL_EX and further, are on line >17=2E >> >> Code >> =3D=3D=3D=3D >> >> 1 > 2 >> 3 namespace ICanBoogie\Validate\Validator; >> 4 >> 5 class Required2 >> 6 { >> 7 const ALIAS =3D 'required'; >> 8 const DEFAULT_MESSAGE =3D "is required"; >> 9 const OPTION_STOP_ON_ERROR =3D 'stop_on_error'; >> 10 >> 11 public function normalize_params(array $params) >> 12 { >> 13 return array_merge([ >> 14 >> 15 self::OPTION_STOP_ON_ERROR =3D> true >> 16 >> 17 ], $params); >> 18 } >> 19 } >> >> >> PHP 7=2E1=2E3 (no OPcache) >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> >> filename: /tmp/xdebug-bug-1/lib/Required2=2Ephp >> function name: normalize_params >> number of ops: 14 >> compiled vars: !0 =3D $params >> line #* E I O op fetch ext=20 >return >> operands >> ------------------------------------------------------------ >> ------------------------- >> 11 0 E > EXT_NOP >> 1 RECV !0 >> 13 2 EXT_STMT >> 3 INIT_NS_FCALL_BY_NAME >> 4 EXT_FCALL_BEGIN >> 15 5 FETCH_CLASS_CONSTANT ~1 >> 'OPTION_STOP_ON_ERROR' >> 17 6 INIT_ARRAY ~2 >> , ~1 >> 7 SEND_VAL_EX >> ~2 >> 8 SEND_VAR_EX >> !0 >> 9 DO_FCALL_BY_NAME >> 10 EXT_FCALL_END >> 11 > RETURN >> $3 >> 18 12* EXT_STMT >> 13* > RETURN >> null >> >> >> PHP 7=2E1=2E3 (OPcache) >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> >> filename: /tmp/xdebug-bug-1/lib/Required2=2Ephp >> function name: normalize_params >> number of ops: 11 >> compiled vars: !0 =3D $params >> line #* E I O op fetch ext=20 >return >> operands >> ------------------------------------------------------------ >> ------------------------- >> 11 0 E > EXT_NOP >> 1 RECV !0 >> 13 2 EXT_STMT >> 3 INIT_NS_FCALL_BY_NAME >> 4 EXT_FCALL_BEGIN >> 17 5 INIT_ARRAY ~1 >> , 'stop_on_error' >> 6 SEND_VAL_EX >> ~1 >> 7 SEND_VAR_EX >> !0 >> 8 DO_FCALL 0 $1 >> 9 EXT_FCALL_END >> 10 > RETURN >> $1 >> >> >> PHP 7=2E1=2E4 (no OPcache) >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> >> filename: /tmp/xdebug-bug-1/lib/Required2=2Ephp >> function name: normalize_params >> number of ops: 14 >> compiled vars: !0 =3D $params >> line #* E I O op fetch ext=20 >return >> operands >> ------------------------------------------------------------ >> ------------------------- >> 11 0 E > EXT_NOP >> 1 RECV !0 >> 13 2 EXT_STMT >> 3 INIT_NS_FCALL_BY_NAME >> 4 EXT_FCALL_BEGIN >> 15 5 FETCH_CLASS_CONSTANT ~1 >> 'OPTION_STOP_ON_ERROR' >> 6 INIT_ARRAY ~2 >> , ~1 >> 7 SEND_VAL_EX >> ~2 >> 8 SEND_VAR_EX >> !0 >> 9 DO_FCALL_BY_NAME >> 10 EXT_FCALL_END >> 11 > RETURN >> $3 >> 18 12* EXT_STMT >> 13* > RETURN >> null >> >> >> PHP 7=2E1=2E4 (OPcache) >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> >> filename: /tmp/xdebug-bug-1/lib/Required2=2Ephp >> function name: normalize_params >> number of ops: 11 >> compiled vars: !0 =3D $params >> line #* E I O op fetch ext=20 >return >> operands >> ------------------------------------------------------------ >> ------------------------- >> 11 0 E > EXT_NOP >> 1 RECV !0 >> 13 2 EXT_STMT >> 3 INIT_NS_FCALL_BY_NAME >> 4 EXT_FCALL_BEGIN >> 15 5 INIT_ARRAY ~1 >> , 'stop_on_error' >> 6 SEND_VAL_EX >> ~1 >> 7 SEND_VAR_EX >> !0 >> 8 DO_FCALL 0 $1 >> 9 EXT_FCALL_END >> 10 > RETURN >> $1 >> >> cheers, >> Derick >> > >This is due to >https://github=2Ecom/php/php-src/commit/183cd048f18fa4b04fb30448a84a54cee= 80a2491, >which fixed lineno assignment for list AST nodes=2E This changed the >start >lineno of the array from line 17 (the end of the array) to line 15 (the >first array element)=2E Of course this is still inaccurate (the actual >start >line is 13), but it's the closest we can get with the information we >currently have available=2E > >The problem in this case is that the second SEND_VAR_EX did not bump >the >lineno=2E I've fixed this in >https://github=2Ecom/php/php-src/commit/e433c23b96e81340cd0e2d0b4b7f5fce7= f72a931 >=2E > >This required a change to an existing test, which alerted me to some >weird >behavior I wasn't aware of: https://3v4l=2Eorg/6fSRb In backtraces the >call >is located on the line of it's last argument (in PHP 5=2E6 the line of >the >closing ")")=2E Wouldn't it make more sense to use the starting line of >the >call? That is, use the same lineno for INIT_FCALL and DO_FCALL? > >Nikita It makes sense to me to use the first line, as long as further opcodes wil= l have the right line number=2E Selfishly, I'd prefer if that change was only made for master, due to the = increasingly complex tests I need to make for Xdebug's code coverage=2E cheers, Derick