From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 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 22D0C1F55B for ; Sat, 23 May 2020 20:18:48 +0000 (UTC) Received: from localhost ([::1]:53706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcabW-00061a-SY for normalperson@yhbt.net; Sat, 23 May 2020 16:18:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcabP-0005za-SF for bug-gnulib@gnu.org; Sat, 23 May 2020 16:18:39 -0400 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::5]:32742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcabN-0002Uu-Jl for bug-gnulib@gnu.org; Sat, 23 May 2020 16:18:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1590265113; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=1hpCxcacyRWYzt5cRAUaICPenYRyBuY7Od9spU4tu10=; b=GN84gh2boNDiHPM1oNEmgg+HDd3lkD2iG/wGBRV4c2gn4WS+r6qgdAitcWHHBj3H1s XYIEWcKfc+FzcTwBpejn6LGJgMKSkT9AkvXKqcPPHb1edtQk1yvLGaL+GIwG22OccKhl 7ECUlJRIOiCaYHYg0MjwPaN0bJ99C/RZCT45zNxW79PrVFPj3fyXT4zt3dBIFzybmPWH RPE/qICIe7AxYtyTsmb5v/QeY9cJ6Co6y8BrxUrPNOJ/gWKuhhvLIJlcCgar9K10iUtC 6f2pXXg83nDAiYqdCQwwBxU4gyOBDB7BN3KWflidroEPPjE2DSjuJUJaJDO9bl3XAlMm geUA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.7.0 DYNA|AUTH) with ESMTPSA id x0bd30w4NKIWQAS (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sat, 23 May 2020 22:18:32 +0200 (CEST) From: Bruno Haible To: Tim =?ISO-8859-1?Q?R=FChsen?= Subject: Fix calloc-gnu configure results Date: Sat, 23 May 2020 22:18:31 +0200 Message-ID: <2627761.id14gx8QEZ@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <10131976.Az27LhXeeQ@omega> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Received-SPF: none client-ip=2a01:238:20a:202:5300::5; envelope-from=bruno@clisp.org; helo=mo6-p00-ob.smtp.rzone.de X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Tim R=FChsen wrote: > - gcc-10 with unset CFLAGS (*.gcc-10) > And the same set with -fsanitize... (*.sanitize). Looking at the differences between config.cache for the gcc-10 without and = with sanitizers, there are some changes that are due to present vs. missing -O2 options (gl_cv_c_inline_effective and possibly gl_cv_func_printf_directive_= n). Other than that: =2Dac_cv_func_calloc_0_nonnull=3D${ac_cv_func_calloc_0_nonnull=3Dyes} +ac_cv_func_calloc_0_nonnull=3D${ac_cv_func_calloc_0_nonnull=3Dno} Here the problem is that in the test program, we expect calloc ((size_t) -1 / 8 + 1, 8) to return NULL, but the AddressSanitizer instead makes the program exit with code 1: configure:45855: ./conftest =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D462953=3D=3DERROR: AddressSanitizer: calloc parameters overflow: co= unt * size (2305843009213693952 * 8) cannot be represented in type size_t (= thread T0) #0 0x7f01a2073037 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.6+0= xaa037) #1 0x5653669731b1 in main (/home/tim/src/testdir-all/conftest+0x11b1) #2 0x7f01a14c2e0a in __libc_start_main ../csu/libc-start.c:308 =3D=3D462953=3D=3DHINT: if you don't care about these errors you may set = allocator_may_return_null=3D1 SUMMARY: AddressSanitizer: calloc-overflow (/usr/lib/x86_64-linux-gnu/lib= asan.so.6+0xaa037) in calloc =3D=3D462953=3D=3DABORTING configure:45855: $? =3D 1 configure: program exited with status 1 This patch fixed it. 2020-05-23 Bruno Haible calloc-gnu: Avoid wrong configure results with GCC's AddressSanitizer. * m4/calloc.m4 (_AC_FUNC_CALLOC_IF): Split the AC_RUN_IFELSE into two AC_RUN_IFELSE invocations. diff --git a/m4/calloc.m4 b/m4/calloc.m4 index 3361cba..a93439e 100644 =2D-- a/m4/calloc.m4 +++ b/m4/calloc.m4 @@ -1,4 +1,4 @@ =2D# calloc.m4 serial 21 +# calloc.m4 serial 22 =20 # Copyright (C) 2004-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -21,33 +21,48 @@ AC_DEFUN([_AC_FUNC_CALLOC_IF], AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([for GNU libc compatible calloc], [ac_cv_func_calloc_0_nonnull], =2D [AC_RUN_IFELSE( =2D [AC_LANG_PROGRAM( =2D [AC_INCLUDES_DEFAULT], =2D [[int result =3D 0; =2D char * volatile p =3D calloc (0, 0); =2D if (!p) =2D result |=3D 1; =2D free (p); =2D p =3D calloc ((size_t) -1 / 8 + 1, 8); =2D if (p) =2D result |=3D 2; =2D free (p); =2D return result; =2D ]])], =2D [ac_cv_func_calloc_0_nonnull=3Dyes], =2D [ac_cv_func_calloc_0_nonnull=3Dno], =2D [case "$host_os" in =2D # Guess yes on glibc systems. =2D *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull=3D"guessing yes" ;; =2D # Guess yes on musl systems. =2D *-musl*) ac_cv_func_calloc_0_nonnull=3D"guessing yes" ;; =2D # Guess yes on native Windows. =2D mingw*) ac_cv_func_calloc_0_nonnull=3D"guessing yes" ;; =2D # If we don't know, obey --enable-cross-guesses. =2D *) ac_cv_func_calloc_0_nonnull=3D"$gl_cross_guess_= normal" ;; =2D esac =2D ])]) + [if test $cross_compiling !=3D yes; then + ac_cv_func_calloc_0_nonnull=3Dyes + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT], + [[int result =3D 0; + char * volatile p =3D calloc (0, 0); + if (!p) + result |=3D 1; + free (p); + return result; + ]])], + [], + [ac_cv_func_calloc_0_nonnull=3Dno]) + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT], + [[int result =3D 0; + char * volatile p =3D calloc ((size_t) -1 / 8 + 1, 8); + if (!p) + result |=3D 2; + free (p); + return result; + ]])], + dnl The exit code of this program is 0 if calloc() succeeded (whi= ch + dnl it shouldn't), 2 if calloc() failed, or 1 if some leak saniti= zer + dnl terminated the program as a result of the calloc() call. + [ac_cv_func_calloc_0_nonnull=3Dno], + []) + else + case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull=3D"guessing yes" ;; + # Guess yes on musl systems. + *-musl*) ac_cv_func_calloc_0_nonnull=3D"guessing yes" ;; + # Guess yes on native Windows. + mingw*) ac_cv_func_calloc_0_nonnull=3D"guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) ac_cv_func_calloc_0_nonnull=3D"$gl_cross_guess_nor= mal" ;; + esac + fi + ]) case "$ac_cv_func_calloc_0_nonnull" in *yes) $1