Created attachment 1859018 [details] preprocessed source Description of problem: On ppc64le: ======================================================================= [mockbuild@3a00fe7f7f694de19171916d75a4f441 h5dump]$ cat test.c #include <stdio.h> #include <stdarg.h> static char buf[4096]; static char gfmt[] = "%Lg"; static int __attribute__ ((noinline)) foo(char *str, const char *fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vsnprintf(str, 4096, fmt, ap); va_end(ap); return ret; } int main(void) { long double dval = 128; int ret = foo(buf, gfmt, dval); fprintf(stdout, "ret[%d]\n", ret); fprintf(stdout, "buf[%s]\n", buf); return 0; } [mockbuild@3a00fe7f7f694de19171916d75a4f441 h5dump]$ gcc -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -DNDEBUG -UH5_DEBUG_API -I../../../src -std=c99 -Wall -Wcast-qual -Wconversion -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-include-dirs -Wno-c++-compat -Wno-format-nonliteral -Wshadow -Wundef -Wwrite-strings -pedantic -Wlarger-than=2560 -Wlogical-op -Wframe-larger-than=16384 -Wpacked-bitfield-compat -Wsync-nand -Wstrict-overflow=5 -Wno-unsuffixed-float-constants -Wdouble-promotion -Wtrampolines -Wstack-usage=8192 -Wmaybe-uninitialized -Wdate-time -Warray-bounds=2 -Wc99-c11-compat -Wduplicated-cond -Whsa -Wnormalized -Wnull-dereference -Wunused-const-variable -Walloca -Walloc-zero -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 -Wrestrict -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2 -Wattribute-alias=2 -Wmissing-profile -Wc11-c2x-compat -fstdarg-opt -fdiagnostics-urls=never -fno-diagnostics-color -s -Wno-aggregate-return -Wno-inline -Wno-missing-format-attribute -Wno-missing-noreturn -Wno-overlength-strings -Wno-jump-misses-init -Wno-suggest-attribute=const -Wno-suggest-attribute=noreturn -Wno-suggest-attribute=pure -Wno-suggest-attribute=format -Wno-suggest-attribute=cold -Wno-suggest-attribute=malloc -Wbad-function-cast -Wimplicit-function-declaration -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-sign -Wpointer-to-int-cast -Wredundant-decls -Wstrict-prototypes -Wswitch -Wunused-function -Wunused-variable -Wunused-parameter -Wcast-align -Wunused-but-set-variable -Wformat -Wincompatible-pointer-types -Wshadow -Wcast-function-type -Wmaybe-uninitialized -O3 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -o testfoo test.c && ./testfoo test.c:4:13: warning: size of 'buf' 4096 bytes exceeds maximum object size 2560 [-Wlarger-than=] 4 | static char buf[4096]; | ^~~ ret[1] buf[0] ======================================================================= Apparently the result is not okay, with -O0: ret[3] buf[128] Version-Release number of selected component (if applicable): gcc-12.0.1-0.4.fc36.ppc64le How reproducible: 100%
The problem seems to be in glibc. I reduced the compiler call to gcc -std=c99 -O1 -Wp,-D_FORTIFY_SOURCE=2 -o test test.c && ./test
I've already fixed it in gcc.
FEDORA-2022-fba9d09417 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-fba9d09417
FEDORA-2022-fba9d09417 has been pushed to the Fedora 36 stable repository. If problem still persists, please make note of it in this bug report.