[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SA_RESETHAND
From: |
Bruno Haible |
Subject: |
SA_RESETHAND |
Date: |
Thu, 21 May 2020 17:15:38 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; ) |
Tim Rühsen 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 <signal.h>
int
main ()
{
struct sigaction act;
act.sa_flags = /* SA_NODEFER | SA_ONSTACK | */ SA_RESETHAND;
return 0;
}
$ clang -Wall foo.c -E | grep sa_flags
int sa_flags;
act.sa_flags = 0x80000000;
$ clang -Wall foo.c -fsanitize=implicit-integer-sign-change
$ ./a.out
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
-2147483648 (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 int'
to 'int'.
How to resolve this?
- Should glibc define SA_RESETHAND as ((int)0x80000000) ?
Then SA_RESETHAND could not be used in preprocessor directives any more.
- Should clang be silent about this case of implicit conversion?
- Should we discourage users from using -fsanitize=implicit-integer-sign-change?
Bruno
[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html
- Fix exponentl.m4 test, (continued)
- Fix exponentl.m4 test, Bruno Haible, 2020/05/23
- Fix calloc.m4 test, Bruno Haible, 2020/05/23
- Re: Fix calloc.m4 test, Paul Eggert, 2020/05/23
- Re: Fix calloc.m4 test, Bruno Haible, 2020/05/23
- Re: Fix calloc.m4 test, Paul Eggert, 2020/05/23
- Re: Fix calloc.m4 test, Bruno Haible, 2020/05/24
- Fix invalid use of __builtin_isnanf and __builtin_isnanl, Bruno Haible, 2020/05/23
- Fix calloc-gnu configure results, Bruno Haible, 2020/05/23
- Re: Fix memleak in getdelim.m4, Bruno Haible, 2020/05/23
- Re: Fix memleak in getdelim.m4, Tim Rühsen, 2020/05/24
- SA_RESETHAND,
Bruno Haible <=
- Re: SA_RESETHAND, Paul Eggert, 2020/05/21
- Re: SA_RESETHAND, Bruno Haible, 2020/05/21
- Re: Fix sanitizer error in fchownat.m4, Bruno Haible, 2020/05/21
- Fix memleak in glob.m4, Bruno Haible, 2020/05/21
- Fix memleak in regex.m4, Bruno Haible, 2020/05/21
- Re: Fix memleak in getdelim.m4, Bruno Haible, 2020/05/21
- Re: Fix memleak in getdelim.m4, Paul Eggert, 2020/05/21
- Re: Fix memleak in getdelim.m4, Bruno Haible, 2020/05/21
Re: Fix memleak in getdelim.m4, Bruno Haible, 2020/05/21