From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id CB6B63858437 for ; Tue, 25 Jan 2022 01:08:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB6B63858437 Received: by mail-pj1-x1029.google.com with SMTP id h12so18136053pjq.3 for ; Mon, 24 Jan 2022 17:08:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=BkwrlOF348+B283MMrL7Gk5Pt//jmup4RwvoB3uLdcQ=; b=psFtlIWuiKDoIgI2OL6FaOpkMJnAhgvQ+PwqCIH1L++hu98YsehmZAWdl9oCz58C8d +jopLa3NDsJngJqNmqcOkqcn/rT1PBugEV1ttNPMMJyOn5yKfMP+jmtgWpkpq74H59L2 tMWQX0a6xv2fHS+ONezUz3fZ2TemEEuq6oBICcGhTJMbnXJMNE+s7Qs1qqPbB7HPnd8v pzAIYPw2BiC0au12xbLrHY5YEUj4wBKc3h0hGVJkZcSuESQuYhY2jEGxHvjjq9HvJJOU hwItoPEdgdkYz1DavMzKPDl8v5nd5D8FX7ZXae9RX7DLIiOpp1oSZAvQQsDtJY0nLcmq cHgQ== X-Gm-Message-State: AOAM532JlaFuoxjjGYwhGO+mougTGAYlFhYnFF6QCLNr4yYkTETk4ATS c9t2jj4bNGMtD4jNv/QsYF3XpCcxnsA= X-Google-Smtp-Source: ABdhPJyuwHU15BCjNM3UdjR0N0ZJqotfZZpcJJy4yNU/JfhYxDjo1LEyM0m79Oq48Q7nQETjGs+RaA== X-Received: by 2002:a17:902:aa43:b0:14a:ca21:979a with SMTP id c3-20020a170902aa4300b0014aca21979amr17363145plr.18.1643072881742; Mon, 24 Jan 2022 17:08:01 -0800 (PST) Received: from [172.31.0.204] (c-73-63-24-84.hsd1.ut.comcast.net. [73.63.24.84]) by smtp.gmail.com with ESMTPSA id w4sm12860556pgs.28.2022.01.24.17.08.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jan 2022 17:08:01 -0800 (PST) Message-ID: <9bd62338-fc2a-c9e8-f14b-df8c9a0f5f72@gmail.com> Date: Mon, 24 Jan 2022 18:08:00 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] avoid -Wuse-after-free [BZ #26779] Content-Language: en-US To: Martin Sebor , Paul Eggert Cc: libc-alpha@sourceware.org References: <6c44a5a2-ed1e-abfe-2ead-9ddb6a97b8fc@gmail.com> <62758b96-42b1-c199-0bf1-975ca4b70cb0@gmail.com> From: Jeff Law In-Reply-To: <62758b96-42b1-c199-0bf1-975ca4b70cb0@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2022 01:08:04 -0000 On 1/24/2022 5:42 PM, Martin Sebor via Libc-alpha wrote: > On 1/21/22 17:42, Paul Eggert wrote: >> On 1/21/22 15:14, Martin Sebor wrote: >>>> >>> >>> That does look cleaner although it wasn't entirely obvious to me >>> from looking at the code that it's the same.  Unfortunately, it >>> doesn't help.  GCC replaces the bool variable with the equality >>> test of the two pointers, and the warning points that out. >> >> That's a GCC bug. >> >>> Pedantically speaking it's a bug in GCC that it does that but >>> I doubt anyone would care to do anything about it. >> >> You might be surprised; they do fix bugs in this area. If I could >> reproduce the bug I'd file a bug report, but my GCC doesn't complain >> so I guess it's up to you.... > > I opened a GCC bug for the record: >   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104215 > GCC 12 is now in its regression-fixing stage so to get it fixed we'd > need to make it a regression.  That's usually only done for bugs that > trigger under conditions where they didn't before. The problem is there's no way for the compiler to know that it can't move the use of q past the realloc call -- there's nothing from a dataflow standpoint which would prevent such movement. In some ways the builtin_realloc call would need to say "I'm going to clobber this argument" and it would have to do so before translating into SSA form I think. Jeff