Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57758 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20747 invoked from network); 6 Feb 2012 05:52:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Feb 2012 05:52:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:55300] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CD/00-18104-6AA6F2F4 for ; Mon, 06 Feb 2012 00:52:38 -0500 Received: by vcbfk13 with SMTP id fk13so4185691vcb.29 for ; Sun, 05 Feb 2012 21:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=jHY6VwIB0UEp1F9tUh03MwfeaWdNhRuJfD8hjXA+B/4=; b=klr2wi3Go5k/7YZI8TmszQAmxFiAVR5/SZm4CiPo1TI2jqo9uIqtzRnQRUxC+DRHbb CUjAXd7ApTQzBV5BvK+XQflduBTg+1ZDpHG3dndSfbBc1qZ02zpigGDHoWAM70z9cz+5 wJgp+JXZ0A1/XxLTHNyA3gVRChP4poYGH2k8c= Received: by 10.220.149.212 with SMTP id u20mr8603240vcv.7.1328507555470; Sun, 05 Feb 2012 21:52:35 -0800 (PST) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.205.137 with HTTP; Sun, 5 Feb 2012 21:52:15 -0800 (PST) In-Reply-To: <4F2F0176.1000104@php.net> References: <4F2EDE20.50207@php.net> <4F2EFB75.6010204@sugarcrm.com> <4F2F0176.1000104@php.net> Date: Mon, 6 Feb 2012 13:52:15 +0800 X-Google-Sender-Auth: hwF3TYdfLHZ1_NEblOMmDJ3VN-c Message-ID: To: Rasmus Lerdorf , Dmitry Stogov Cc: Stas Malyshev , "internals@lists.php.net" , Sebastian Bergmann Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Static Analysis of PHP_5_4 with CLANG From: laruence@php.net (Laruence) On Mon, Feb 6, 2012 at 6:23 AM, Rasmus Lerdorf wrote: > On 02/05/2012 01:58 PM, Stas Malyshev wrote: >> Hi! >> >>> =C2=A0 http://clang-php54.phpunit.de/ might be of interest to some. >>> =C2=A0 http://bit.ly/u06eCD has details of how to produce this report. >> >> Thanks, definitely is a useful thing. Though I'm not sure if this tool >> is always right. For example, I looked at >> http://clang-php54.phpunit.de/report-dqJzsw.html#EndPath, and it claims >> in line 1331 replacement is garbage. However, the only way to get there >> is to pass through (flags & ENT_HTML_SUBSTITUTE_DISALLOWED_CHARS), and >> if (flags & ENT_HTML_SUBSTITUTE_DISALLOWED_CHARS) is not 0 then >> replacement is initialized in lines 1245-1252 by one of the clauses. >> Looks like this tool does not remember the branches it took before. Am I >> missing something here or should we submit a bug report to CLANG devs? > > I checked scan.coverity and it didn't find any problems in > ext/standard/html.c > > The Coverity scan does find a bunch of possible null-dereferences. > > For example, in zend_compile.c: > > 3075 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if > (!strcasecmp(arg_info->class_name, "self") && fptr->common.scope ) { > 3076 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cl= ass_name =3D > fptr->common.scope->name; > 3077 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cl= ass_name_len =3D > fptr->common.scope->name_length; > 3078 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} else if > (!strcasecmp(arg_info->class_name, "parent") && > fptr->common.scope->parent) { > > The if on 3075 implies that fptr->common.scope could be null and then in > the else if on 3078 fptr->common.scope->parent is checked. Now, it > probably means that every time arg_info->class_name is set to "parent" > fptr->common.scope will be defined, but a static analyzer isn't able to > detect that. Note also that this code only appears in trunk. The 5.4 > code is completely different. Was this a missed trunk commit? Rasmus: this is a fix for #60573. since 5.4 is in freeze period, so I hold from = 5.4. and IMO if the classname is set to "self", then the scope could not be NULL, obviously the code is in-appropriate. I will fix it. Dmitry, could you give me some advise on this plz? thanks > > -Rasmus > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/