Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114604 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15360 invoked from network); 25 May 2021 22:32:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 May 2021 22:32:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5DA1F1804C3 for ; Tue, 25 May 2021 15:43:25 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 May 2021 15:43:24 -0700 (PDT) Received: by mail-ej1-f50.google.com with SMTP id k14so46349866eji.2 for ; Tue, 25 May 2021 15:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tqiSJWrxrjSVLrNbyROX0LnWDua1vZofcc/+HRGnMac=; b=OqconpZCY5GgkGenXSzNYB+Avr8bysTN3ERs8NMY/Qx4lRtyjXC/te56q7AnDZQKqI NCzsZmBE2rlYIl2XYKqUWenCzdX2yeYy2/bI2d+c+sNkmWgqD8+JoIUQ0OQJVWC2Z9+p qnsRgZhshXreHwMQS0DSh2MemYiQCaphgUpuSMOvyc39enjKaUFyXSL3cqkc32lCxqcx 1NCqkEtpOcFfdFF2BGMdUDX6SOMmUy176LAjXd2ZFFu+RPMZPUZ4qerZCla0DYqszj4t N78Ncl6ibXHl2tO8OUw6FE5o4SyPqDKsSxVXRqmYGqcqHkl8beDP1SRfVvBzS6AnO6dF Zq+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tqiSJWrxrjSVLrNbyROX0LnWDua1vZofcc/+HRGnMac=; b=Nmh2fRyQF1l/05eOLeuEcFxWojHwLQHtEB26P4JzmRiAuI4hyYeE0VzObzmx+FBf2h +WIa3DyuhybaX7j9oJ4BTj8ifcNxZclPqN2sJOYpIslvlSJLeDOtoczGcO8VZtQ+5tVc lt+L7J4w7TumuPgMyR1SVE0GhIm8Oy3S2QpUQfXCaO8JGNZoVSnyQTLn6TnoeyPOCVn6 mpKa5V6f7mokVq+3QSlqWNLoGSO3cEKeFqkzGRlKWX8KzlBCn38Ek8IF71gOQsYikTkZ hZhoZUJwaLKbyHY3Edx1NPYqXxlcX49fG+l6YLbpamYTlsQOPV21SVEW9BiyCcx+DqkM yseQ== X-Gm-Message-State: AOAM532e7iqKNxDHsxvNL85OxTg8tp2HVFMz7Jw+FFeYVX5U3TH0yYNG mfcO6t8XoFlu5jAscQBURx+vZMybSCGoWnMeKtAtT09ZmSo= X-Google-Smtp-Source: ABdhPJzHC6q8u+jYkqJvquSDnGnIv65cQlt+EWpzNGc+EQNA3jgRTRsxNK7TQK1Ys2exOmzo/j1vxrpvyEKVBXbmNRg= X-Received: by 2002:a17:906:b30f:: with SMTP id n15mr14053902ejz.406.1621982601145; Tue, 25 May 2021 15:43:21 -0700 (PDT) MIME-Version: 1.0 References: <194DA850-19F7-41C4-97CF-944F13B57AFD@cmpct.info> <7AD8D5D3-C70E-40C3-B55E-A4C9E4ECDA44@cmpct.info> In-Reply-To: <7AD8D5D3-C70E-40C3-B55E-A4C9E4ECDA44@cmpct.info> Date: Tue, 25 May 2021 23:43:10 +0100 Message-ID: To: Calvin Buckley Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000c5f1b705c32f4079" Subject: Re: [PHP-DEV] Using clang-analyzer with PHP: experiences? From: george.banyard@gmail.com ("G. P. B.") --000000000000c5f1b705c32f4079 Content-Type: text/plain; charset="UTF-8" On Tue, 25 May 2021 at 21:10, Calvin Buckley wrote: > I did some additional research and seemed to have decent luck with > slamming a construct like this after the includes: > > #define emalloc malloc > #define erealloc realloc > #define ecalloc calloc > #define estrdup strdup > #define estrndup strndup > #define efree free > > One could wrap it around `__clang_analyzer__` or such. Unfortunately, this > is kinda ugly; it emits compiler warnings, but I suspect this probably > belongs in PHP itself or perhaps in some kind of clang-analyzer addon that > handles the e* allocation functions as well as things like mismatching them. > Isn't this handled by the GCC 11? The existing malloc > > attribute has been extended so that it can be used to identify > allocator/deallocator API pairs. A pair of new -Wmismatched-dealloc > > and -Wmismatched-new-delete > > warnings will complain about mismatched calls, and -Wfree-nonheap-object > > about deallocation calls with pointers not obtained from allocation > functions. Additionally, the static analyzer will use these attributes when > checking for leaks, double-frees, use-after-frees, and similar issues. > From: https://gcc.gnu.org/gcc-11/changes.html Best regards, George P. Banyard --000000000000c5f1b705c32f4079--