meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
ubsan causes wrong -Wformat-overflow warnings as follows:
In file included from /usr/include/stdio.h:906,
from /home/alarm/q/var/qemu/include/qemu/osdep.h:114,
from ../disas/cris.c:21:
In function 'sprintf',
inlined from 'format_dec' at ../disas/cris.c:1737:3,
inlined from 'print_with_operands' at ../disas/cris.c:2477:12,
inlined from 'print_insn_cris_generic.constprop' at ../disas/cris.c:2690:8:
/usr/include/bits/stdio2.h:30:10: warning: null destination pointer [-Wformat-overflow=]
30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
Don't let these errors stop the build.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
meson.build | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index d7d841e71e..02f1a18080 100644
--- a/meson.build
+++ b/meson.build
@@ -365,7 +365,9 @@ if get_option('sanitizers')
# Detect static linking issue with ubsan - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
if cc.links('int main(int argc, char **argv) { return argc + 1; }',
args: [qemu_ldflags, '-fsanitize=undefined'])
- qemu_cflags = ['-fsanitize=undefined'] + qemu_cflags
+ # 87884 – ubsan causes wrong -Wformat-overflow warning
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87884
+ qemu_cflags = ['-fsanitize=undefined', '-Wno-error=format-overflow'] + qemu_cflags
qemu_ldflags = ['-fsanitize=undefined'] + qemu_ldflags
endif
endif
--
2.42.1
Hi Akihiko, On 20/11/23 12:23, Akihiko Odaki wrote: > ubsan causes wrong -Wformat-overflow warnings as follows: > > In file included from /usr/include/stdio.h:906, > from /home/alarm/q/var/qemu/include/qemu/osdep.h:114, > from ../disas/cris.c:21: > In function 'sprintf', > inlined from 'format_dec' at ../disas/cris.c:1737:3, > inlined from 'print_with_operands' at ../disas/cris.c:2477:12, > inlined from 'print_insn_cris_generic.constprop' at ../disas/cris.c:2690:8: > /usr/include/bits/stdio2.h:30:10: warning: null destination pointer [-Wformat-overflow=] > 30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 31 | __glibc_objsize (__s), __fmt, > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 32 | __va_arg_pack ()); > | ~~~~~~~~~~~~~~~~~ > > Don't let these errors stop the build. Which compiler/version? > > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> > --- > meson.build | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/meson.build b/meson.build > index d7d841e71e..02f1a18080 100644 > --- a/meson.build > +++ b/meson.build > @@ -365,7 +365,9 @@ if get_option('sanitizers') > # Detect static linking issue with ubsan - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 > if cc.links('int main(int argc, char **argv) { return argc + 1; }', > args: [qemu_ldflags, '-fsanitize=undefined']) > - qemu_cflags = ['-fsanitize=undefined'] + qemu_cflags > + # 87884 – ubsan causes wrong -Wformat-overflow warning > + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87884 > + qemu_cflags = ['-fsanitize=undefined', '-Wno-error=format-overflow'] + qemu_cflags > qemu_ldflags = ['-fsanitize=undefined'] + qemu_ldflags > endif > endif
On 20/11/23 14:16, Philippe Mathieu-Daudé wrote: > Hi Akihiko, > > On 20/11/23 12:23, Akihiko Odaki wrote: >> ubsan causes wrong -Wformat-overflow warnings as follows: >> >> In file included from /usr/include/stdio.h:906, >> from /home/alarm/q/var/qemu/include/qemu/osdep.h:114, >> from ../disas/cris.c:21: >> In function 'sprintf', >> inlined from 'format_dec' at ../disas/cris.c:1737:3, >> inlined from 'print_with_operands' at ../disas/cris.c:2477:12, >> inlined from 'print_insn_cris_generic.constprop' at >> ../disas/cris.c:2690:8: >> /usr/include/bits/stdio2.h:30:10: warning: null destination pointer >> [-Wformat-overflow=] >> 30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> 31 | __glibc_objsize (__s), __fmt, >> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> 32 | __va_arg_pack ()); >> | ~~~~~~~~~~~~~~~~~ >> >> Don't let these errors stop the build. > > Which compiler/version? > >> >> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> >> --- >> meson.build | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/meson.build b/meson.build >> index d7d841e71e..02f1a18080 100644 >> --- a/meson.build >> +++ b/meson.build >> @@ -365,7 +365,9 @@ if get_option('sanitizers') >> # Detect static linking issue with ubsan - >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 >> if cc.links('int main(int argc, char **argv) { return argc + 1; }', >> args: [qemu_ldflags, '-fsanitize=undefined']) >> - qemu_cflags = ['-fsanitize=undefined'] + qemu_cflags >> + # 87884 – ubsan causes wrong -Wformat-overflow warning >> + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87884 I posted an alternative less intrusive patch, see: https://lore.kernel.org/all/20231120132222.82138-1-philmd@linaro.org/ >> + qemu_cflags = ['-fsanitize=undefined', >> '-Wno-error=format-overflow'] + qemu_cflags >> qemu_ldflags = ['-fsanitize=undefined'] + qemu_ldflags >> endif >> endif >
© 2016 - 2024 Red Hat, Inc.