From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 4B7B81F47C for ; Thu, 5 Jan 2023 17:28:18 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eLQGiOCN; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDTrF-0003xN-SX; Thu, 05 Jan 2023 12:16:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDTrD-0003uc-DP for bug-gnulib@gnu.org; Thu, 05 Jan 2023 12:16:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDTrB-0003a5-Ra for bug-gnulib@gnu.org; Thu, 05 Jan 2023 12:16:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672939004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=N9l4D9iOdOhHHJcuPmJlEZ6UnAqIaGAlDHjgsSLYJe8=; b=eLQGiOCNq00N4Q0Zmv5YPSMm/wBHn0sW8TjgYLYq6g+viftfzkew067pMa5kZMnwcj87IX qhmmNOSwX6DAD3GjBD/Ggvvmosf0ajfgmZ0UONLGdCOCoVN6beULeHhLPrCeDhAuyCIh5G JTyQ5bymxPh7iKkKoImrhXQZhvWZ3Nw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-qdatLiC8NDOvlPzzWpEXpw-1; Thu, 05 Jan 2023 12:16:43 -0500 X-MC-Unique: qdatLiC8NDOvlPzzWpEXpw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2A3FC1818E68; Thu, 5 Jan 2023 17:16:43 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90DD140C2064; Thu, 5 Jan 2023 17:16:42 +0000 (UTC) From: Florian Weimer To: Bruno Haible Cc: bug-gnulib@gnu.org Subject: Re: xmalloc calling undeclared xalloc_die function References: <87cz8slruc.fsf@oldenburg.str.redhat.com> <2518769.sP1CNn8AQk@nimes> Date: Thu, 05 Jan 2023 18:16:41 +0100 In-Reply-To: <2518769.sP1CNn8AQk@nimes> (Bruno Haible's message of "Fri, 09 Dec 2022 17:08:35 +0100") Message-ID: <87lemgnbpi.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Received-SPF: pass client-ip=170.10.129.124; envelope-from=fweimer@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org * Bruno Haible: > Florian Weimer wrote: >> lib/xmalloc.c contains this function definition, unconditionally: >> >> static void * _GL_ATTRIBUTE_PURE >> nonnull (void *p) >> { >> if (!p) >> xalloc_die (); >> return p; >> } >> >> But the declaration of xalloc_die in lib/xalloc.h is conditional: >> >> #if GNULIB_XALLOC_DIE >> >> /* This function is always triggered when memory is exhausted. >> It must be defined by the application, either explicitly >> or by using gnulib's xalloc-die module. This is the >> function to call when one wants the program to die because of a >> memory allocation failure. */ >> /*extern*/ _Noreturn void xalloc_die (void); >> >> #endif /* GNULIB_XALLOC_DIE */ > > It's conditional on the C macro GNULIB_XALLOC_DIE, which is defined by > the module 'xalloc-die' (file modules/xalloc-die, line 15). > > This conditional was added through > > 1) to avoid link errors with a compiler that does not eliminate unused > inline functions, > 2) to trigger a compilation error instead of a link error or runtime error > when a packages requerts 'xalloc-die' without 'xalloc' or vice versa > but then actually uses both. > >> I have a package (lbzip2 ) which >> supplies its own definition of xalloc_die, and fails to build due to an >> undeclared function. > > This package calls gnulib-tool like this: > > gnulib-tool --avoid=xalloc-die --add-import pthread utimens warnings \ > timespec-add timespec-sub dtotimespec stat-time lstat malloc-gnu \ > fprintf-posix inttypes xalloc largefile gitlog-to-changelog > > This means, the module 'xalloc-die' is not included, thus xalloc.h does > not provide the declaration of xalloc_die(). > > There are at least three possible fixes: > > * Rather than '--avoid=xalloc-die', the package could override parts > of the 'xalloc-die' module, as described in > . > > * The package could define the C macro GNULIB_XALLOC_DIE. > > * The package could declare xalloc_die(). > > I would probably pick the second one. Thanks, this was helpful. Submitted a patch: Define the GNULIB_XALLOC_DIE macro Florian