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 7147B1F55B for ; Thu, 21 May 2020 15:15:55 +0000 (UTC) Received: from localhost ([::1]:33226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbmvK-0004yt-KJ for normalperson@yhbt.net; Thu, 21 May 2020 11:15:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbmvA-0004yf-K8 for bug-gnulib@gnu.org; Thu, 21 May 2020 11:15:44 -0400 Received: from mo6-p01-ob.smtp.rzone.de ([2a01:238:20a:202:5301::4]:14654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbmv8-0000in-W4 for bug-gnulib@gnu.org; Thu, 21 May 2020 11:15:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1590074140; 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=Wm0jQPEP/6G//Db8+/sjOK0YL5ANxeD3YlDT+Vr3SFY=; b=N1lY+tyki9FMm0ef+7XyUbApO4Y7wY8YDt218hRhhtQYcuMLtJZ9Cx3TAZjZYNh0ba irXg+kVsUpdB3OVmNXJh6wpG/L6TNTgm1rqzCNt63u8UPB7JR5DxSANwBKLkFooslnmC 4cG7kDiOLbJbAtapGn6YbDKgmqrKfFlwQ6A0pPn4SNGgX3PkuA+6nV2BIPepznBqVlMI VD38pLiw6k+Ei9o8Ws/IMJhKH1iKR3siXAUpd6Q7WGmuso0AoC3Jw2qRe1N7s/atUdhw wXHNvVLrm3Wi86B0tU3KDJdwn0dpOmB3z92x7Kr9T/73TFI60TerI0JN1w/hL1Gpeg5a V/nA== 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 x0bd30w4LFFdCmS (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); Thu, 21 May 2020 17:15:39 +0200 (CEST) From: Bruno Haible To: Tim =?ISO-8859-1?Q?R=FChsen?= Subject: SA_RESETHAND Date: Thu, 21 May 2020 17:15:38 +0200 Message-ID: <1914708.U9Lh6kAjoy@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <3816106.4I1b13x7fG@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:5301::4; envelope-from=bruno@clisp.org; helo=mo6-p01-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 reports: > configure:14038: checking for working C stack overflow detection > SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change Here's a reduced test case: $ cat foo.c #include int main () { struct sigaction act; act.sa_flags =3D /* SA_NODEFER | SA_ONSTACK | */ SA_RESETHAND; return 0; } $ clang -Wall foo.c -E | grep sa_flags int sa_flags; act.sa_flags =3D 0x80000000; $ clang -Wall foo.c -fsanitize=3Dimplicit-integer-sign-change $ ./a.out=20 foo.c:7:50: runtime error: implicit conversion from type 'unsigned int' of = value 2147483648 (32-bit, unsigned) to type 'int' changed the value to -214= 7483648 (32-bit, signed) So, glibc defines the 'sa_flags' field as being of type 'int' (like POSIX [1] mandates). glibc also defines SA_RESETHAND as 0x80000000. The compiler interprets this constant as being of type 'unsigned int'. The sanitizer then complains about an implicit conversion from 'unsigned in= t' to 'int'. How to resolve this? =2D Should glibc define SA_RESETHAND as ((int)0x80000000) ? Then SA_RESETHAND could not be used in preprocessor directives any more. =2D Should clang be silent about this case of implicit conversion? =2D Should we discourage users from using -fsanitize=3Dimplicit-integer-sig= n-change? Bruno [1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.ht= ml