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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6F5503858D28 for ; Thu, 21 Jul 2022 12:36:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6F5503858D28 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-195-o-gNN_i5M5OuxFFJn6dySw-1; Thu, 21 Jul 2022 08:36:24 -0400 X-MC-Unique: o-gNN_i5M5OuxFFJn6dySw-1 Received: by mail-qk1-f199.google.com with SMTP id f20-20020a05620a409400b006b5fc740485so1235695qko.12 for ; Thu, 21 Jul 2022 05:36:24 -0700 (PDT) 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:references:from:organization:in-reply-to :content-transfer-encoding; bh=rlpInU+gX6HLz8c+4pgb0HRgggReVnVv54CzBxjDYqc=; b=KTn1Pjifnk9kECyeiW8mPhsRHypVKn6m6fZNR7jix2GQpw3XGTCbbOnIWCOoxq4JHK xMLj+jA2nahC37VKrrylZAtZiH68uXhf3j86AVUwj/MbhJzprXrmK/0NnbvY4p4pqG1i oKyWiughIa4mGnbzRzJhBbfVEiYJ8OqGRgnXhW4E6nQvBY+5ZbTaBKWzTNaMaYi25PLn U8rzjgyHURhT3HWhipEhk3V03KcVS9ZFi2yCk6MVMIrE1nEct4FHH95OQ/hb8OP63Bzp 1TyTcvJ50fqw7EfTLd6PvD+/+OE0iLEfjXDGysc4v+ncdnYntDNSkCVgl6lskf4K5nOT LQLg== X-Gm-Message-State: AJIora8PSNbAk0PudOoIG/ZVPoLf2yfmeEZrfxearMB+foy5iB504JQR 7vG237rv1hy0mlF+sJhDrusoI02tPtlH4P7lbKAGhPix1wdVUCjQmbttOUZG0S5KobrcLOV38MA 5itmOpbiUGxnWekqwkF63 X-Received: by 2002:a05:6214:29e3:b0:473:7170:dafd with SMTP id jv3-20020a05621429e300b004737170dafdmr33299547qvb.38.1658406983447; Thu, 21 Jul 2022 05:36:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u3a21dc/ztPBaHY03t/ZQIyHofjknHe3j7DBDjSUYQ8GyezzWdmBWNG2mAyCDz8h5xOEDTog== X-Received: by 2002:a05:6214:29e3:b0:473:7170:dafd with SMTP id jv3-20020a05621429e300b004737170dafdmr33299532qvb.38.1658406983160; Thu, 21 Jul 2022 05:36:23 -0700 (PDT) Received: from [192.168.0.241] (192-0-145-146.cpe.teksavvy.com. [192.0.145.146]) by smtp.gmail.com with ESMTPSA id w22-20020a05620a425600b006b28349678dsm1346747qko.80.2022.07.21.05.36.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Jul 2022 05:36:22 -0700 (PDT) Message-ID: Date: Thu, 21 Jul 2022 08:36:21 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] malloc: Simplify implementation of __malloc_assert To: Siddhesh Poyarekar , Florian Weimer , libc-alpha@sourceware.org References: <87a6924uvf.fsf@oldenburg.str.redhat.com> From: Carlos O'Donell Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Thu, 21 Jul 2022 12:36:26 -0000 On 7/21/22 07:43, Siddhesh Poyarekar wrote: > On 2022-07-21 06:34, Florian Weimer via Libc-alpha wrote: >> It is prudent not to run too much code after detecting heap >> corruption, and __fxprintf is really complex.  The line number >> and file name do not carry much information, so it is not included >> in the error message.  (__libc_message only supports %s formatting.) >> The function name and assertion should provide some context. >> >> Tested on i686-linux-gnu and x86_64-linux-gnu.  Also emulated the >> __libc_message call using GDB, and it produced the expected output. >> >> Thanks, >> Florian >> --- > > LGTM. > > Reviewed-by: Siddhesh Poyarekar Approved as RM for glibc 2.36. This avoids us calling malloc down the failing path. >   malloc/malloc.c | 15 +++++---------- >>   1 file changed, 5 insertions(+), 10 deletions(-) >> >> diff --git a/malloc/malloc.c b/malloc/malloc.c >> index 12908b8f97..bd3c76ed31 100644 >> --- a/malloc/malloc.c >> +++ b/malloc/malloc.c >> @@ -292,19 +292,14 @@ >>   # define __assert_fail(assertion, file, line, function)            \ >>        __malloc_assert(assertion, file, line, function) >>   -extern const char *__progname; >> - >> -static void >> +_Noreturn static void >>   __malloc_assert (const char *assertion, const char *file, unsigned int line, >>            const char *function) >>   { >> -  (void) __fxprintf (NULL, "%s%s%s:%u: %s%sAssertion `%s' failed.\n", >> -             __progname, __progname[0] ? ": " : "", >> -             file, line, >> -             function ? function : "", function ? ": " : "", >> -             assertion); >> -  fflush (stderr); >> -  abort (); >> +  __libc_message (do_abort, "\ >> +Fatal glibc error: malloc assertion failure in %s: %s\n", >> +          function, assertion); >> +  __builtin_unreachable (); >>   } >>   #endif >>   #endif >> > -- Cheers, Carlos.