Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100989 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32191 invoked from network); 30 Oct 2017 08:20:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Oct 2017 08:20:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=xinchen.h@zend.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=laruence@php.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 209.85.216.177 cause and error) X-PHP-List-Original-Sender: xinchen.h@zend.com X-Host-Fingerprint: 209.85.216.177 mail-qt0-f177.google.com Received: from [209.85.216.177] ([209.85.216.177:48617] helo=mail-qt0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B3/B4-07742-4C0E6F95 for ; Mon, 30 Oct 2017 03:20:22 -0500 Received: by mail-qt0-f177.google.com with SMTP id f8so15301716qta.5 for ; Mon, 30 Oct 2017 01:20:20 -0700 (PDT) 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=wuyHBnibXbyViCoMuU/ND3749/F7zTROp4hrZDDugKc=; b=YsAVNAf5UDYLkE7/8Pmtw05cHmPMxD4qMHOnIfd5/1RZTGiIklbH54/+PkmsPeM2gH Z5ZosL25Q9xEsV0p57PN/FTHru9WiYkKC1e5PZsFCt8qRkVP3OOjzc4hTiiU/jXDiZmV Bbir2O96zjA0Wl9aKz5LiygtDhg4k2XiOnVMMejM1hr9MwF3Ak7+PHgvGpGMkxaC6XzI yuy42ytzMFj3hF8m4XtdsMN+YXdYbAldPTELb0DxUcslzJzBMhrAsEPbHCIph0XI/umF aP5caI0rMOWa5zF9elyvNawKd29EpFPPaiPS7MZEjnwkHqeF4tKFDjtQBILYpjHF90// ZSdQ== X-Gm-Message-State: AMCzsaWZld2xT4ST/P+AKoVR4NYXNXhMMntA+GwJVy0QT4hCJTvSKL/x 3DogH3OKMIjFHHuP6GiVYmrw5Q0O X-Google-Smtp-Source: ABhQp+TLf6zky9tfKAlEQ1pzPNJSBMWd4H51zHYpgUFB6C+7vjd5j1Qb7Ja9CEq/gWc+4BSybouLxA== X-Received: by 10.200.27.116 with SMTP id p49mr13224257qtk.336.1509351616935; Mon, 30 Oct 2017 01:20:16 -0700 (PDT) Received: from mail-qk0-f175.google.com (mail-qk0-f175.google.com. [209.85.220.175]) by smtp.gmail.com with ESMTPSA id s187sm9079351qke.68.2017.10.30.01.20.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 01:20:15 -0700 (PDT) Received: by mail-qk0-f175.google.com with SMTP id k123so15103758qke.3 for ; Mon, 30 Oct 2017 01:20:15 -0700 (PDT) X-Received: by 10.55.133.65 with SMTP id h62mr12065390qkd.130.1509351615152; Mon, 30 Oct 2017 01:20:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.167.154 with HTTP; Mon, 30 Oct 2017 01:19:54 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 Oct 2017 16:19:54 +0800 X-Gmail-Original-Message-ID: Message-ID: To: Dmitry Stogov Cc: Derick Rethans , Nikita Popov , PHP Developers Mailing List Content-Type: multipart/alternative; boundary="94eb2c07d424dcc7ce055cbf4e83" Subject: Re: [PHP-DEV] Weird PHP 7.2 bug From: laruence@php.net (Xinchen Hui) --94eb2c07d424dcc7ce055cbf4e83 Content-Type: text/plain; charset="UTF-8" Hey: On Mon, Oct 30, 2017 at 3:55 PM, Dmitry Stogov wrote: > Fixed. thanks. for catching. > Great thanks > The real problem - incorrect handling of "wrong index type. > > In this situation PHP should keep input array unchanged. > Inferring types "by usage" makes sense (for array) > > e.g. $a[$n]++ should change the type of array. > I > > Thanks. Dmitry. > > > ------------------------------ > *From:* Xinchen Hui > *Sent:* Monday, October 30, 2017 10:05:30 AM > *To:* Derick Rethans > *Cc:* Dmitry Stogov; Nikita Popov; PHP Developers Mailing List > *Subject:* Re: [PHP-DEV] Weird PHP 7.2 bug > > Hey: > > On Mon, Oct 30, 2017 at 2:48 AM, Derick Rethans wrote: > >> Hi, >> >> running: >> https://raw.githubusercontent.com/xdebug/xdebug/master/tests/bug01263.inc >> >> with: >> $ php -n -dzend_extension=opcache.so -dopcache.enable_cli=1 >> tests/bug01263.inc >> >> Produces the following output with PHP 7.2 build at Oct 29 2017 18:49:58: >> >> In function PHP_CodeCoverage::addUncoveredFilesFromWhitelist (after >> sccp): >> var 10 (CV $data) has array value type but not key type >> var 15 (CV $data) has array value type but not key type >> var 21 (CV $data) has array value type but not key type >> >> In function PHP_CodeCoverage::addUncoveredFilesFromWhitelist (after >> calls): >> var 10 (CV $data) has array value type but not key type >> var 15 (CV $data) has array value type but not key type >> var 21 (CV $data) has array value type but not key type >> >> In function PHP_CodeCoverage::addUncoveredFilesFromWhitelist (after dce): >> var 10 (CV $data) has array value type but not key type >> var 15 (CV $data) has array value type but not key type >> var 21 (CV $data) has array value type but not key type >> >> In function PHP_CodeCoverage::addUncoveredFilesFromWhitelist (after dfa): >> var 10 (CV $data) has array value type but not key type >> var 15 (CV $data) has array value type but not key type >> var 21 (CV $data) has array value type but not key type >> > First, this won't bring any harm to execution, this is becuase we know $uncoveredFiles > are IS_UNDEF for sure(thus the foreach block actually won't be executed), > > > then in typeinfo inference system, we will get $uncoveredFile with type > info 0. > > then later while doing type inference for ZEND_FETCH_W ($data[$uncoveredFile][$i] > = ), since $unconveredFile has 0 type info, thus we won't get any key info > of the array ($data), > > but in the current type inference system, FETCH_W's result will be used in > ASSIGN_DIM , then the system think $data maybe an array of > array(MAY_BE_ARRAY_OF_ARRAY). > > which result: has array value type but not key type > > anyway, I think infer type infos by usage is wrong here, we should only > trust def info, not use info... > > so, I propose fix this by: https://gist.github.com/laruence/ > 9990ce5f9f3b30dd98dbff4f59109232 > > Dmitry, what do you think? > > thanks > >> >> >> cheers, >> Derick >> >> -- >> https://derickrethans.nl | https://xdebug.org | https://dram.io >> Like Xdebug? Consider a donation: https://xdebug.org/donate.php >> twitter: @derickr and @xdebug >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > > > -- > Xinchen Hui > @Laruence > http://www.laruence.com/ > -- Xinchen Hui @Laruence http://www.laruence.com/ --94eb2c07d424dcc7ce055cbf4e83--