[Bug 1196279] New: gcc12 doesn't like kernel's fortify-string.h
https://bugzilla.suse.com/show_bug.cgi?id=1196279 Bug ID: 1196279 Summary: gcc12 doesn't like kernel's fortify-string.h Classification: openSUSE Product: openSUSE Tumbleweed Version: Current Hardware: Other OS: Other Status: NEW Severity: Normal Priority: P5 - None Component: Development Assignee: rguenther@suse.com Reporter: jslaby@suse.com QA Contact: qa-bugs@suse.de Found By: --- Blocker: --- Created attachment 856404 --> https://bugzilla.suse.com/attachment.cgi?id=856404&action=edit one preprocessed example When building a kernel using gcc 12, I see a lot of:
In file included from /home/latest/linux/include/linux/string.h:253, from /home/latest/linux/include/linux/bitmap.h:11, from /home/latest/linux/include/linux/cpumask.h:12, from /home/latest/linux/arch/x86/include/asm/cpumask.h:5, from /home/latest/linux/arch/x86/include/asm/msr.h:11, from /home/latest/linux/arch/x86/include/asm/processor.h:22, from /home/latest/linux/arch/x86/include/asm/cpufeature.h:5, from /home/latest/linux/arch/x86/include/asm/thread_info.h:53, from /home/latest/linux/include/linux/thread_info.h:60, from /home/latest/linux/arch/x86/include/asm/preempt.h:7, from /home/latest/linux/include/linux/preempt.h:78, from /home/latest/linux/include/linux/spinlock.h:55, from /home/latest/linux/include/linux/mmzone.h:8, from /home/latest/linux/include/linux/gfp.h:6, from /home/latest/linux/include/linux/mm.h:7, from /home/latest/linux/mm/swapfile.c:9: /home/latest/linux/include/linux/fortify-string.h: In function ���memcmp���: /home/latest/linux/include/linux/fortify-string.h:391:5: warning: infinite recursion detected [-Winfinite-recursion] 391 | int memcmp(const void * const POS0 p, const void * const POS0 q, __kernel_size_t size) | ^~~~~~ /home/latest/linux/include/linux/fortify-string.h:44:33: note: recursive call 44 | #define __underlying_memcmp __builtin_memcmp | ^ /home/latest/linux/include/linux/fortify-string.h:404:16: note: in expansion of macro ���__underlying_memcmp��� 404 | return __underlying_memcmp(p, q, size); | ^~~~~~~~~~~~~~~~~~~
It's like this: #define __underlying_memcmp __builtin_memcmp __FORTIFY_INLINE __diagnose_as(__builtin_memcmp, 1, 2, 3) int memcmp(const void * const POS0 p, const void * const POS0 q, __kernel_size_t size) { ... return __underlying_memcmp(p, q, size); } I suppose it's a gcc bug... -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1196279 https://bugzilla.suse.com/show_bug.cgi?id=1196279#c1 --- Comment #1 from Jiri Slaby <jslaby@suse.com> --- (In reply to Jiri Slaby from comment #0)
Created attachment 856404 [details] one preprocessed example
That's useless as the interesting parts are gone. Maybe it's __diagnose_as which is causing the recursion, defined in include/linux/compiler_attributes.h as: #if __has_attribute(__diagnose_as_builtin__) # define __diagnose_as(builtin...) __attribute__((__diagnose_as_builtin__(builtin))) #else # define __diagnose_as(builtin...) #endif -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1196279 https://bugzilla.suse.com/show_bug.cgi?id=1196279#c2 --- Comment #2 from Jiri Slaby <jslaby@suse.com> --- (In reply to Jiri Slaby from comment #1)
Maybe it's __diagnose_as which is causing the recursion, defined in include/linux/compiler_attributes.h as: #if __has_attribute(__diagnose_as_builtin__) # define __diagnose_as(builtin...) __attribute__((__diagnose_as_builtin__(builtin))) #else # define __diagnose_as(builtin...) #endif
Or not, it's not supported by gcc, so it expands to nothing. -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1196279 https://bugzilla.suse.com/show_bug.cgi?id=1196279#c3 --- Comment #3 from Jiri Slaby <jslaby@suse.com> --- (In reply to Jiri Slaby from comment #1)
(In reply to Jiri Slaby from comment #0)
Created attachment 856404 [details] one preprocessed example
That's useless as the interesting parts are gone.
So: The kernel: https://github.com/openSUSE/kernel/tree/stable The config: https://github.com/openSUSE/kernel-source/blob/stable/config/x86_64/default The command line it issues: gcc-12 -Wp,-MMD,mm/.mempolicy.o.d -nostdinc -I/home/latest/linux/arch/x86/include -I./arch/x86/include/generated -I/home/latest/linux/include -I./include -I/home/latest/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/latest/linux/include/uapi -I./include/generated/uapi -include /home/latest/linux/include/linux/compiler-version.h -include /home/latest/linux/include/linux/kconfig.h -include /home/latest/linux/include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=/home/latest/linux/= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wimplicit-fallthrough=5 -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-stack-clash-protection -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -Wno-alloc-size-larger-than -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -g -gdwarf-4 -I /home/latest/linux/mm -I ./mm -DKBUILD_MODFILE='"mm/mempolicy"' -DKBUILD_BASENAME='"mempolicy"' -DKBUILD_MODNAME='"mempolicy"' -D__KBUILD_MODNAME=kmod_mempolicy -c -o mm/mempolicy.o /home/latest/linux/mm/mempolicy.c -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1196279 https://bugzilla.suse.com/show_bug.cgi?id=1196279#c4 Richard Biener <rguenther@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=104633 --- Comment #4 from Richard Biener <rguenther@suse.com> --- We are diagnosing inline __attribute__((always_inline)) int memcmp (const void * p, const void *q, unsigned long size) { return __builtin_memcmp (p, q, size); } I suppose glibcs fortify wrappers are not diagnosed because they are guarded with -Wsystem-header. I've filed an upstream bug. -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1196279 https://bugzilla.suse.com/show_bug.cgi?id=1196279#c5 --- Comment #5 from Jiri Slaby <jslaby@suse.com> --- (In reply to Jiri Slaby from comment #1)
(In reply to Jiri Slaby from comment #0)
Created attachment 856404 [details] one preprocessed example
That's useless as the interesting parts are gone.
Not that useless, if you turn on the warning (and optimizations) :P: gcc-12 -O2 -Winfinite-recursion -S -o /dev/null /tmp/mempolicy.i /home/latest/linux/include/linux/fortify-string.h:391:5: warning: infinite recursion detected [-Winfinite-recursion] (Or -Wall.) -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1196279 https://bugzilla.suse.com/show_bug.cgi?id=1196279#c6 --- Comment #6 from Richard Biener <rguenther@suse.com> --- Note glibc dispatches to the extern via an alias instead of a #define to a builtin: extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n, size_t __destlen) __attribute__ ((__nothrow__ , __leaf__)); extern char *__stpncpy_alias (char *__dest, const char *__src, size_t __n) __asm__ ("" "stpncpy") __attribute__ ((__nothrow__ , __leaf__)) ; extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char * __attribute__ ((__nothrow__ , __leaf__)) stpncpy (char *__dest, const char *__src, size_t __n) { if (__builtin_object_size (__dest, 2 > 1) != (size_t) -1 && (!__builtin_constant_p (__n) || __n > __builtin_object_size (__dest, 2
1))) return __stpncpy_chk (__dest, __src, __n, __builtin_object_size (__dest, 2 1)); return __stpncpy_alias (__dest, __src, __n); }
that might be a way to avoid the diagnostic. -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1196279 https://bugzilla.suse.com/show_bug.cgi?id=1196279#c7 Richard Biener <rguenther@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #7 from Richard Biener <rguenther@suse.com> --- Should be fixed now. -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1196279 https://bugzilla.suse.com/show_bug.cgi?id=1196279#c8 Jiri Slaby <jslaby@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |VERIFIED --- Comment #8 from Jiri Slaby <jslaby@suse.com> --- (In reply to Richard Biener from comment #7)
Should be fixed now.
Judging from: https://build.opensuse.org/package/live_build_log/openSUSE:Factory:Staging:G... Indeed! -- You are receiving this mail because: You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@suse.com