Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103610 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69263 invoked from network); 17 Dec 2018 10:16:19 -0000 Received: from unknown (HELO NAM05-CO1-obe.outbound.protection.outlook.com) (40.107.72.94) by pb1.pair.com with SMTP; 17 Dec 2018 10:16:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BbdgnyTlNKAQmOVxFnURZ8mnB8z1ifXTMiXacCF5XQA=; b=mX+fXTng107/0HkAYQguMm966sbNRD3TLO1eHkI4ko4d74O/elqYSBmnRX23Eih3ZkRGp5rHNSm2U8Jg+pymdH4wE0WxCOihND/a2o4z8PddSvx+5drFE+HmToA1EMAo71IbyI7OCvsHbMVwWggpXkh+lVGxHaEzM1ms9co8fC0= Received: from BY1PR02MB1260.namprd02.prod.outlook.com (10.162.109.14) by BY1PR02MB1194.namprd02.prod.outlook.com (10.162.108.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.22; Mon, 17 Dec 2018 06:44:46 +0000 Received: from BY1PR02MB1260.namprd02.prod.outlook.com ([fe80::c4dc:13f7:8eed:ad32]) by BY1PR02MB1260.namprd02.prod.outlook.com ([fe80::c4dc:13f7:8eed:ad32%4]) with mapi id 15.20.1425.021; Mon, 17 Dec 2018 06:44:46 +0000 To: Derick Rethans CC: Nikita Popov , PHP Developers Mailing List Thread-Topic: Changes to when OPcache initialises Thread-Index: AQHUlKikq+/ulDu/TEuvXY13n9kJHqWCfdCe Date: Mon, 17 Dec 2018 06:44:46 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmitry@zend.com; x-originating-ip: [212.232.72.197] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BY1PR02MB1194;6:FGQUyauUT55DA2dDvPfeNx5KzEcmMqZsPWEpdhdlw6/Z1MHZZ+HDm5Yx5NqT9tJH8VuOtYAM8REyqKRfBC7ZlvdB2vIfHpHdhtc/MWa/tLTi1ZHzZeaSrgXka+MZd4XuJgeuUfxk6a9EiWIW/vVRyEzyLx32K30kX8JFikXYXe+ZZ49MCTJ+BnuUDn7TtIC2pAv9XH86gUDhh6Zw8H27zCfvEbwd/NLaU8grtiaKubqR/qUmRQkZm+gsfYrDPhLAU9GaL5oqO4d1wrNWD+sKyok80Jh8uOOoJcxSpz/DYkQuWmZYFb2/G7vZkx9VTFcEF1Z9BriFi93Bk5g/TQotg3VAnM47Ew4d65OZO5EyrtSdTmES6slBau4nCZ+oRleoyDsGc5jxk6ljCNT9STWy9/OAeMc+Zv0M9hnvv2q8tkRa7BWcYUPvAH/6qhouAqlOO2QsPiOuqPdiv65RthgluA==;5:cUxyoxI8Ix5YsotKDPUOZj4r5j/Op5y1gBalSrDc/pE+to/ka9aEWZZMHMDiwsr1jXWf+xXcdY3Li9bieB1S5FvKajg3Vkd9M91gp7hcAJDBnH0NWS4qRXBs83AXNNhqLBjDfA289I+pzpr3kTJ1bd2Y6mBMJXx925kAyELNXdw=;7:VrJTMWd/hiHpqoWC65He0oFX4WaUaRBKHclpC3aJ8dE78hZ4lDRHMuF38wiqqaUeKZv1iicUxjvxVQxvDGOenpofn/3eiiKJfxf/MyEEmLhX1UUcNqK7aZibCS95LpCMlSBwWPfbKxqhoU7ay6gpSw== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 670fd427-1f89-473f-45a5-08d663eb2267 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR02MB1194; x-ms-traffictypediagnostic: BY1PR02MB1194: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(3230021)(999002)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231475)(944501520)(52105112)(10201501046)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699051)(76991095);SRVR:BY1PR02MB1194;BCL:0;PCL:0;RULEID:;SRVR:BY1PR02MB1194; x-forefront-prvs: 08897B549D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39840400004)(396003)(366004)(376002)(136003)(346002)(199004)(189003)(53936002)(99286004)(316002)(74316002)(54906003)(256004)(6246003)(25786009)(186003)(26005)(6436002)(486006)(68736007)(76176011)(229853002)(7696005)(476003)(6306002)(446003)(102836004)(55016002)(11346002)(97736004)(236005)(54896002)(6606003)(19627405001)(39060400002)(2906002)(71190400001)(71200400001)(7736002)(8676002)(105586002)(6916009)(5660300001)(8936002)(4326008)(53546011)(106356001)(33656002)(81166006)(6506007)(81156014)(66066001)(9686003)(606006)(14454004)(16799955002)(3846002)(6116002)(575784001)(86362001)(966005)(14444005)(478600001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR02MB1194;H:BY1PR02MB1260.namprd02.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: zend.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: mgY91jU35jaopJphoPfEJuSvU9ceNK95EuzgaZR0on6YnGMOxnw9J4U5K16ZFoEvuQiPQSm0P+3r9tlxIAmiOvxn17WaJINds298J08/tfX95UYkS7UrFEx1SdvksUVNndFLKo1iwdOkjOSgWKKm/t9cYQWqeorETRtZ0qxSaN9wacM77qkjvL+NfnE2Wv72G+JI2LJIwx8VU7nkjED3SiG5Vh1hq/K4F+8j0NoyxTxU1Kay1l1QDZCg/EGJRZV6QF9rOKWJVvXdD8wlum3eF6zSlEiMORr7SpRsRlrS8Qghozizcv5l1aI7MO1bwMzx spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_BY1PR02MB1260B8650F7279B77C09534FBFBC0BY1PR02MB1260namp_" MIME-Version: 1.0 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-Network-Message-Id: 670fd427-1f89-473f-45a5-08d663eb2267 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2018 06:44:46.3911 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB1194 Subject: Re: Changes to when OPcache initialises From: dmitry@zend.com (Dmitry Stogov) --_000_BY1PR02MB1260B8650F7279B77C09534FBFBC0BY1PR02MB1260namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi Derick, First, check why VLD works out of the box. At second, you may plug into post_startup hook to reassign zend_compile aft= er opcache. Thanks. Dmitry. ________________________________ From: Derick Rethans Sent: Saturday, December 15, 2018 10:01:37 PM To: Dmitry Stogov Cc: Nikita Popov; PHP Developers Mailing List Subject: Changes to when OPcache initialises Hi! I am working on making Xdebug work properly with PHP 7.3, and over the last week I have been tearing my hair out as to why Xdebug's view of opcodes was no longer showing the opcodes that OPcache had modified/optimised. In PHP 7.2, the order in which you load Xdebug and OPcache made a difference. OPcache optimises out line 6, which has dead code: 1 derick@singlemalt:~/dev/php/derickr-xdebug $ /usr/local/php/7.2.13/bin/php = -n -dzend_extension=3Dopcache.so -d "zend_extension=3Dxdebug.so" -d "opca= che.enable=3D1" -d "opcache.enable_cli=3D1" -d "xdebug.extended_info=3D1" -= dvld.active=3D1 -f "/home/derick/dev/php/derickr-xdebug/tests/bug00213-php7= 3-opcache.php" 48 /home/derick/dev/php/derickr-xdebug/tests/bug00213-php73-opcache.php:7: array(4) { [5] =3D> int(1) [8] =3D> int(1) [12] =3D> int(1) [14] =3D> int(1) } [GIT: issue1598-no-code-coverage-with-opcache][PHP: 7.2.13 ] derick@singlemalt:~/dev/php/derickr-xdebug $ /usr/local/php/7.2.13/bin/php = -n -d "zend_extension=3Dxdebug.so" -dzend_extension=3Dopcache.so -d "opca= che.enable=3D1" -d "opcache.enable_cli=3D1" -d "xdebug.extended_info=3D1" -= dvld.active=3D1 -f "/home/derick/dev/php/derickr-xdebug/tests/bug00213-php7= 3-opcache.php" 48 /home/derick/dev/php/derickr-xdebug/tests/bug00213-php73-opcache.php:7: array(5) { [5] =3D> int(1) [6] =3D> int(-2) [8] =3D> int(1) [12] =3D> int(1) [14] =3D> int(1) } Where as with PHP 7.3.0, they both show the *unoptimised* version: derick@singlemalt:~/dev/php/derickr-xdebug $ /usr/local/php/7.3.0/bin/php = -n -dzend_extension=3Dopcache.so -d "zend_extension=3Dxdebug.so" -d "opcac= he.enable=3D1" -d "opcache.enable_cli=3D1" -d "xdebug.extended_info=3D1" -d= vld.active=3D1 -f "/home/derick/dev/php/derickr-xdebug/tests/bug00213-php73= -opcache.php" 48 /home/derick/dev/php/derickr-xdebug/tests/bug00213-php73-opcache.php:7: array(5) { [5] =3D> int(1) [6] =3D> int(-2) [8] =3D> int(1) [12] =3D> int(1) [14] =3D> int(1) } [GIT: issue1598-no-code-coverage-with-opcache][PHP: 7.2.13 ] derick@singlemalt:~/dev/php/derickr-xdebug $ /usr/local/php/7.3.0/bin/php = -n -d "zend_extension=3Dxdebug.so" -dzend_extension=3Dopcache.so -d "opcac= he.enable=3D1" -d "opcache.enable_cli=3D1" -d "xdebug.extended_info=3D1" -d= vld.active=3D1 -f "/home/derick/dev/php/derickr-xdebug/tests/bug00213-php73= -opcache.php" 48 /home/derick/dev/php/derickr-xdebug/tests/bug00213-php73-opcache.php:7: array(5) { [5] =3D> int(1) [6] =3D> int(-2) [8] =3D> int(1) [12] =3D> int(1) [14] =3D> int(1) } Curiously, vld, would always show the right (optimised) opcodes: filename: /home/derick/dev/php/derickr-xdebug/tests/bug00213.inc function name: (null) number of ops: 12 compiled vars: !0 =3D $e line #* E I O op fetch ext return = operands ---------------------------------------------------------------------------= ---------- 5 0 E > EXT_STMT 1 NEW $1 = :-5 2 EXT_FCALL_BEGIN 3 DO_FCALL 0 4 EXT_FCALL_END 5 > THROW 0 = $1 8 6 E > > CATCH = 'Exception', !0 12 7 > EXT_STMT 8 ECHO = 48 9 EXT_STMT 10 ECHO = '%0A' 14 11 > RETURN = 1 branch: # 0; line: 5- 5; sop: 0; eop: 5; out0: -2 branch: # 6; line: 8- 8; sop: 6; eop: 6; out0: 7; out1: = -2 branch: # 7; line: 12- 14; sop: 7; eop: 11; out0: -2 path #1: 0, path #2: 6, 7, So I did some digging and found out that OPcache in PHP 7.3 has had a chang= e to the loading order. This was done in: https://github.com/php/php-src/commit/b4903aef16ec215f2095ff0a3615524656401= 660: commit b4903aef16ec215f2095ff0a3615524656401660 Author: Dmitry Stogov Date: Wed Oct 18 17:18:54 2017 +0300 Move a part of opcache initialization into post_startup pha= se (when all extensions already loaded). Both Xdebug and OPcache hook into zend_compile. In PHP 7.2, when as per documentation, OPcache was loaded after Xdebug, OPcache's zend_compile (accel_startup) was run *first*, so that Xdebug sees the optimised opcodes. In PHP 7.3, after the above commit, Xdebug's zend_compile hook (xdebug_compile_file) is run before OPcache's =97 *no matter which extension is loaded first*. Due to this, Xdebug can not properly do code coverage anymore when OPcache is also present, as it can only see *unoptimised* oparrays during its zend_compile hook. Because opcodes may now differ between when Xdebug analyses oparrays (zend_compile stage) and when it uses it (zend_execute stage) the results can be inconsistent in OPcache has optimised things away, and/or rearranged branches. Right now, I don't think I have a choice but to disallow code coverage analysis when OPcache is present, but I would prefer finding a solution to this so that OPcache and Xdebug work together again, as it did for PHP versions before 7.3. cheers, Derick -- https://derickrethans.nl | https://xdebug.org | https://dram.io Like Xdebug? Consider a donation: https://xdebug.org/donate.php, or become my Patron: https://www.patreon.com/derickr twitter: @derickr and @xdebug --_000_BY1PR02MB1260B8650F7279B77C09534FBFBC0BY1PR02MB1260namp_--