From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id LTZmLYyqjmCMIgAAWB0awg (envelope-from ) for ; Sun, 02 May 2021 09:35:08 -0400 Received: by simark.ca (Postfix, from userid 112) id AD4FB1F11C; Sun, 2 May 2021 09:35:08 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0C0AC1E783 for ; Sun, 2 May 2021 09:35:08 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B410B383303F; Sun, 2 May 2021 13:35:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B410B383303F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1619962507; bh=202Irsd9GmT3I/HRv0JqcRKBsO2CvPM1r+TU81pcNeo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=twEGnqXPO712xpQRAtOf6URwgCRwqggP1oTANRVoK1cLVkazWbY0MNu3A4FkWxhH1 aU7PDsPuwkhQCi6mgcaCFWu02xZwJpgyyJd4uOgOSsWJqOvKW/C5erdEF4G1PAYqPL Sv+UiJ9LWTrzWrOva91FX/DpicJuOh2yt6SNQNbU= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 8EE473833024 for ; Sun, 2 May 2021 13:35:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8EE473833024 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-594-pgossseDNwyYByuedGIfjw-1; Sun, 02 May 2021 09:35:02 -0400 X-MC-Unique: pgossseDNwyYByuedGIfjw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 402B818397BB for ; Sun, 2 May 2021 13:35:01 +0000 (UTC) Received: from host1.jankratochvil.net (unknown [10.40.192.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA1EE5D9D3 for ; Sun, 2 May 2021 13:35:00 +0000 (UTC) Date: Sun, 2 May 2021 15:34:58 +0200 To: gdb-patches@sourceware.org Subject: [patch] Fix LD_PRELOAD=/usr/lib64/libasan.so.6 gdb Message-ID: MIME-Version: 1.0 User-Agent: Mutt/2.0.6 (2021-03-06) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="x5kpyAUhx88m9ZkU" Content-Disposition: inline X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jan Kratochvil via Gdb-patches Reply-To: Jan Kratochvil Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" --x5kpyAUhx88m9ZkU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x613000000040 https://bugzilla.redhat.com/show_bug.cgi?id=1510413 The gdb binary had so far on Fedora 34 x86_64: U operator delete[](void*) U operator delete[](void*, unsigned long) U operator delete(void*, unsigned long) While now there are defined all these - but IMO it is a bit unpredictable which will be used in the future: 00000000000000c0 T operator delete[](void*) 00000000000000d0 T operator delete[](void*, std::nothrow_t const&) 00000000000000e0 T operator delete[](void*, unsigned long) 0000000000000090 T operator delete(void*) 00000000000000a0 T operator delete(void*, std::nothrow_t const&) 00000000000000b0 T operator delete(void*, unsigned long) Jan --x5kpyAUhx88m9ZkU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename=1 gdbsupport/ 2021-05-02 Jan Kratochvil * new-op.cc (opertor delete 6x): New. diff --git a/gdbsupport/new-op.cc b/gdbsupport/new-op.cc index 5ab19621a43..f70d3ef191d 100644 --- a/gdbsupport/new-op.cc +++ b/gdbsupport/new-op.cc @@ -92,4 +92,44 @@ operator new[] (std::size_t sz, const std::nothrow_t&) noexcept { return ::operator new (sz, std::nothrow); } + +/* Define also operators delete as one can LD_PRELOAD=libasan.so.* + without recompiling the program with -fsanitize=address . */ + +void +operator delete (void *p) +{ + free (p); +} + +void +operator delete (void *p, const std::nothrow_t&) noexcept +{ + return ::operator delete (p); +} + +void +operator delete (void *p, std::size_t) noexcept +{ + return ::operator delete (p, std::nothrow); +} + +void +operator delete[] (void *p) +{ + return ::operator delete (p); +} + +void +operator delete[] (void *p, const std::nothrow_t&) noexcept +{ + return ::operator delete (p, std::nothrow); +} + +void +operator delete[] (void *p, std::size_t) noexcept +{ + return ::operator delete[] (p, std::nothrow); +} + #endif --x5kpyAUhx88m9ZkU--