[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/25] configure: Avoid -Werror=maybe-uninitialized
From: |
Paolo Bonzini |
Subject: |
[PULL 07/25] configure: Avoid -Werror=maybe-uninitialized |
Date: |
Fri, 21 Apr 2023 11:32:58 +0200 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
The configure script used to compile some code which dereferences memory
with ubsan to verify the compiler can link with ubsan library which
detects dereferencing of uninitialized memory. However, as the
dereferenced memory was allocated in the same code, GCC can statically
detect the unitialized memory dereference and emit maybe-uninitialized
warning. If -Werror is set, this becomes an error, and the configure
script incorrectly thinks the error indicates the compiler cannot use
ubsan.
Fix this error by replacing the code with another function which adds
1 to a signed integer argument. This brings in ubsan to detect if it
causes signed integer overflow. As the value of the argument cannot be
statically determined, the new function is also immune to compiler
warnings.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230405070030.23148-1-akihiko.odaki@daynix.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/configure b/configure
index 6ed66ec6abda..22b8553b8d70 100755
--- a/configure
+++ b/configure
@@ -1749,13 +1749,9 @@ if test "$sanitizers" = "yes" ; then
# detect the static linking issue of ubsan, see also:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
cat > $TMPC << EOF
-#include <stdlib.h>
-int main(void) {
- void *tmp = malloc(10);
- if (tmp != NULL) {
- return *(int *)(tmp + 2);
- }
- return 1;
+int main(int argc, char **argv)
+{
+ return argc + 1;
}
EOF
if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
--
2.40.0
- [PULL 00/25] First batch of misc patches for QEMU 8.1, Paolo Bonzini, 2023/04/21
- [PULL 01/25] mtest2make.py: teach suite name that are just "PROJECT", Paolo Bonzini, 2023/04/21
- [PULL 02/25] build-sys: prevent meson from downloading wrapped subprojects, Paolo Bonzini, 2023/04/21
- [PULL 03/25] build-sys: add slirp.wrap, Paolo Bonzini, 2023/04/21
- [PULL 05/25] vnc: avoid underflow when accessing user-provided address, Paolo Bonzini, 2023/04/21
- [PULL 04/25] nvme: remove constant argument to tracepoint, Paolo Bonzini, 2023/04/21
- [PULL 06/25] tests: bios-tables-test: replace memset with initializer, Paolo Bonzini, 2023/04/21
- [PULL 07/25] configure: Avoid -Werror=maybe-uninitialized,
Paolo Bonzini <=
- [PULL 09/25] lasi: fix RTC migration, Paolo Bonzini, 2023/04/21
- [PULL 08/25] target/i386: Avoid unreachable variable declaration in mmu_translate(), Paolo Bonzini, 2023/04/21
- [PULL 11/25] target/mips: tcg: detect out-of-bounds accesses to cpu_gpr and cpu_gpr_hi, Paolo Bonzini, 2023/04/21
- [PULL 10/25] coverity: update COMPONENTS.md, Paolo Bonzini, 2023/04/21
- [PULL 13/25] io: mark mixed functions that can suspend, Paolo Bonzini, 2023/04/21
- [PULL 12/25] qapi-gen: mark coroutine QMP command functions as coroutine_fn, Paolo Bonzini, 2023/04/21
- [PULL 18/25] postcopy-ram: do not use qatomic_mb_read, Paolo Bonzini, 2023/04/21
- [PULL 14/25] migration: mark mixed functions that can suspend, Paolo Bonzini, 2023/04/21
- [PULL 15/25] monitor: mark mixed functions that can suspend, Paolo Bonzini, 2023/04/21
- [PULL 16/25] target/i386: Change wrong XFRM value in SGX CPUID leaf, Paolo Bonzini, 2023/04/21