From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id E124B3850400 for ; Fri, 22 Jan 2021 21:26:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E124B3850400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-58-jN8aq42jOJSCxwI7-Ncvcw-1; Fri, 22 Jan 2021 16:26:03 -0500 X-MC-Unique: jN8aq42jOJSCxwI7-Ncvcw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C3A7835B48; Fri, 22 Jan 2021 21:26:02 +0000 (UTC) Received: from greed.delorie.com (ovpn-113-151.rdu2.redhat.com [10.10.113.151]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B200160BE5; Fri, 22 Jan 2021 21:26:01 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.14.7/8.14.7) with ESMTP id 10MLQ0v1015233; Fri, 22 Jan 2021 16:26:00 -0500 From: DJ Delorie To: Martin Sebor Cc: fweimer@redhat.com, libc-alpha@sourceware.org, joseph@codesourcery.com Subject: Re: [PATCH] add support for -Wmismatched-dealloc In-Reply-To: (message from Martin Sebor via Libc-alpha on Mon, 11 Jan 2021 17:01:42 -0700) Date: Fri, 22 Jan 2021 16:26:00 -0500 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 22 Jan 2021 21:26:08 -0000 Martin Sebor via Libc-alpha writes: >> realpath only returns a pointer to the heap if RESOLVED is null, so the >> annotation is wrong here. >> > > This is intentional. When realpath() returns the last argument > (when it's nonnull) passing the returned pointer to free will not > be diagnosed but passing it to some other deallocator not associated > with the function will be. That means for example that passing > a pointer allocated by C++ operator new() to realpath() and then > deleting the pointer returned from the function as opposed to > the argument will trigger a false positive. I decided this was > an okay trade-off because unless the function allocates memory > I expect the returned pointer to be ignored (similarly to how > the pointer returned from memcpy is ignored). If you don't like > the odds I can remove the attribute from the function until we > have one that captures this conditional return value (I'd like > to add one in GCC 12). Do we have a resolution on this? I think deferring the realpath part of this patch until it can be handled correctly is a reasonable solution. I think an unwarned leak is better than false warnings. The rest of the patch looks fine and has been reviewed...