Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98807 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76832 invoked from network); 15 Apr 2017 16:24:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2017 16:24:58 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.169 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.223.169 mail-io0-f169.google.com Received: from [209.85.223.169] ([209.85.223.169:34905] helo=mail-io0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/11-61625-85942F85 for ; Sat, 15 Apr 2017 12:24:57 -0400 Received: by mail-io0-f169.google.com with SMTP id r16so123599799ioi.2 for ; Sat, 15 Apr 2017 09:24:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=RQ+5bCwDeHjz0qX6iUgCDSHwt6NwL+Ao9Xdu+ZLyYsA=; b=r75psaA0ioNAMSC48yAUIb4DrNirDpzqau1yYCtRdBoZf9QW7UUNL6N+tbxCesqbyO kZk6mUzdw5RxPcE7mL+leokHzHt3rX/BPUx0nqrvZgshxi2VdAPcao5zy3P7gRzBWbSI rapnE9d4Odove5OeJxHvSRNlHOBDjr3dlhITVtvrFywMlBqkS2DHFPdHl3ivLFyBIxLw UBs+S0IGvxtsSuOKn2cZ+s4R+o1csDE18jMiFFuiYf7PGkTeMwVD4kvWhEVfrQTm2X0G B8o8Hln+kox3+K1porTHnc5rzIK0eg7QAUVoTENlHEbkGwjb4XF27aprC6QqF7CyJukD qMqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=RQ+5bCwDeHjz0qX6iUgCDSHwt6NwL+Ao9Xdu+ZLyYsA=; b=mdg/mFwTUl2g0Ke/hiw8dzjap9lurMdGK5LQnrImS4/652ahWWoMpwf0SMsXTFwziQ MpXtEHtHq+VX6Ta4BR0j7Q5gVxazdZmC0TSZradBrV9FrUOQSInYkKWdZK6Yd9/mS1PX +AKB4ylFHcEtEdNGQROrPvToCaxRVJGau13dR8Fbm1AUTvbfzH+Y4QgmQIXeHV9TyZKc FN35mYS0ib/lEehCDDLaellvfP5qf4ZuPrw75HdIBKKaGULsQd7f/wrbHEGkAcwMzHCG 170DTUbwF81hrASAYn/9EZbnoWPKwQfLtvj2v9wesgVJucGd5O0hdmVRgvtAUgAulzZN z6zA== X-Gm-Message-State: AN3rC/7MA8JeVQih4y/A4RvHeClnA5oyDky9x5FHa9as3mXsZyTPhNIU wZe2YaE7L9LgPT01V5B1mKWEzySdFmLX X-Received: by 10.107.180.200 with SMTP id d191mr2536347iof.42.1492273493629; Sat, 15 Apr 2017 09:24:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.34.78 with HTTP; Sat, 15 Apr 2017 09:24:53 -0700 (PDT) In-Reply-To: References: Date: Sat, 15 Apr 2017 18:24:53 +0200 Message-ID: To: Derick Rethans Cc: PHP Developers Mailing List Content-Type: multipart/alternative; boundary=94eb2c0685ce7ee054054d36ffb9 Subject: Re: Inconsistency in line numbers. From: nikita.ppv@gmail.com (Nikita Popov) --94eb2c0685ce7ee054054d36ffb9 Content-Type: text/plain; charset=UTF-8 On Sat, Apr 15, 2017 at 5:25 PM, Derick Rethans wrote: > Hi Nikita, > > Through Xdebug bug #1413 (https://bugs.xdebug.org/view.php?id=1413), I > noticed > that behaviour with class constants changed between PHP 7.1.3 and PHP > 7.1.4. > I *believe* it is because of the fix for issue #69676 > (https://bugs.php.net/bug.php?id=69676) that got fixed in PHP 7.1.4. > > With OPcache loaded, the INIT_ARRAY and further opcodes are relisted as > being > on line 15 instead of line 17. Although, I would probably argue that > INIT_ARRAY should really be on line 13 (the opening [). > > Without OPcache loaded, in PHP 7.1.3, FETCH_CLASS_CONSTANT is on line 15, > and > the INIT_ARRAY and further opcodes are on line 17. In PHP 7.1.4, they are > all > on line 15 - with 17 no longer showing up. > > 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. > > Code > ==== > > 1 2 > 3 namespace ICanBoogie\Validate\Validator; > 4 > 5 class Required2 > 6 { > 7 const ALIAS = 'required'; > 8 const DEFAULT_MESSAGE = "is required"; > 9 const OPTION_STOP_ON_ERROR = 'stop_on_error'; > 10 > 11 public function normalize_params(array $params) > 12 { > 13 return array_merge([ > 14 > 15 self::OPTION_STOP_ON_ERROR => true > 16 > 17 ], $params); > 18 } > 19 } > > > PHP 7.1.3 (no OPcache) > ====================== > > filename: /tmp/xdebug-bug-1/lib/Required2.php > function name: normalize_params > number of ops: 14 > compiled vars: !0 = $params > line #* E I O op fetch ext 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.1.3 (OPcache) > ====================== > > filename: /tmp/xdebug-bug-1/lib/Required2.php > function name: normalize_params > number of ops: 11 > compiled vars: !0 = $params > line #* E I O op fetch ext 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.1.4 (no OPcache) > ====================== > > filename: /tmp/xdebug-bug-1/lib/Required2.php > function name: normalize_params > number of ops: 14 > compiled vars: !0 = $params > line #* E I O op fetch ext 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.1.4 (OPcache) > ====================== > > filename: /tmp/xdebug-bug-1/lib/Required2.php > function name: normalize_params > number of ops: 11 > compiled vars: !0 = $params > line #* E I O op fetch ext 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.com/php/php-src/commit/183cd048f18fa4b04fb30448a84a54cee80a2491, which fixed lineno assignment for list AST nodes. This changed the start lineno of the array from line 17 (the end of the array) to line 15 (the first array element). 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. The problem in this case is that the second SEND_VAR_EX did not bump the lineno. I've fixed this in https://github.com/php/php-src/commit/e433c23b96e81340cd0e2d0b4b7f5fce7f72a931 . This required a change to an existing test, which alerted me to some weird behavior I wasn't aware of: https://3v4l.org/6fSRb In backtraces the call is located on the line of it's last argument (in PHP 5.6 the line of the closing ")"). 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 --94eb2c0685ce7ee054054d36ffb9--