[Bug 1158189] New: GCC 10: grub2 build fails
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189 Bug ID: 1158189 Summary: GCC 10: grub2 build fails Classification: openSUSE Product: openSUSE Tumbleweed Version: Current Hardware: Other OS: Other Status: NEW Severity: Normal Priority: P5 - None Component: Basesystem Assignee: bnc-team-screening@forge.provo.novell.com Reporter: martin.liska@suse.com QA Contact: qa-bugs@suse.de Found By: --- Blocker: --- Fails due to: abuild@marxinbox:~/rpmbuild/BUILD/grub-2.04/build-emu/grub-core> gcc -DHAVE_CONFIG_H -I. -I../../grub-core -I.. -Wall -W -DGRUB_MACHINE_EMU=1 -DGRUB_MACHINE=X86_64_EMU -I../../include -I../include -DGRUB_FILE=\"disk/mdraid1x_linux.c\" -I. -I../../grub-core -I.. -I../.. -I../../include -I../include -I../../grub-core/lib/libgcrypt-grub/src/ -D_FILE_OFFSET_BITS=64 -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -freg-struct-return -fno-dwarf2-cfi-asm -mno-stack-arg-probe -fno-asynchronous-unwind-tables -fno-unwind-tables -mcmodel=large -fno-PIE -fno-pie -fno-stack-protector -Wtrampolines -Werror -ffreestanding -fno-strict-aliasing -fno-inline-functions-called-once -MT disk/mdraid1x_module-mdraid1x_linux.o -MD -MP -MF disk/.deps-core/mdraid1x_module-mdraid1x_linux.Tpo -c -o disk/mdraid1x_module-mdraid1x_linux.o `test -f 'disk/mdraid1x_linux.c' || echo '../../grub-core/'`disk/mdraid1x_linux.c ../../grub-core/disk/mdraid1x_linux.c: In function 'grub_mdraid_detect': ../../grub-core/disk/mdraid1x_linux.c:181:15: error: array subscript <unknown> is outside array bounds of 'grub_uint16_t[0]' {aka 'short unsigned int[0]'} [-Werror=array-bounds] 181 | (char *) &sb.dev_roles[grub_le_to_cpu32 (sb.dev_number)] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../grub-core/disk/mdraid1x_linux.c:98:17: note: while referencing 'dev_roles' 98 | grub_uint16_t dev_roles[0]; /* Role in array, or 0xffff for a spare, or 0xfffe for faulty. */ | ^~~~~~~~~ ../../grub-core/disk/mdraid1x_linux.c:127:33: note: defined here 'sb' 127 | struct grub_raid_super_1x sb; | ^~ cc1: all warnings being treated as errors which is a GCC issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92326 -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189
Martin Liška
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189#c5
--- Comment #5 from Martin Liška
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189#c7
--- Comment #7 from Michael Chang
Index: grub-2.04/grub-core/disk/mdraid1x_linux.c =================================================================== --- grub-2.04.orig/grub-core/disk/mdraid1x_linux.c +++ grub-2.04/grub-core/disk/mdraid1x_linux.c @@ -178,7 +178,7 @@ grub_mdraid_detect (grub_disk_t disk, return NULL;
if (grub_disk_read (disk, sector, - (char *) &sb.dev_roles[grub_le_to_cpu32 (sb.dev_number)] + (char *) (sb.dev_roles + grub_le_to_cpu32 (sb.dev_number)) - (char *) &sb, sizeof (role), &role)) return NULL;
And after I encountered more errors from gcc-10 ... -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189
pgnd _
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189#c9
--- Comment #9 from Michael Chang
(In reply to Michael Chang from comment #7)
I used this patch to calculate the pointer without taking address of indexed dev_roles array and it worked fine for me.
Index: grub-2.04/grub-core/disk/mdraid1x_linux.c =================================================================== --- grub-2.04.orig/grub-core/disk/mdraid1x_linux.c +++ grub-2.04/grub-core/disk/mdraid1x_linux.c @@ -178,7 +178,7 @@ grub_mdraid_detect (grub_disk_t disk, return NULL;
if (grub_disk_read (disk, sector, - (char *) &sb.dev_roles[grub_le_to_cpu32 (sb.dev_number)] + (char *) (sb.dev_roles + grub_le_to_cpu32 (sb.dev_number)) - (char *) &sb, sizeof (role), &role)) return NULL;
Technically it still does the same but if it works around the warning it's fine.
Thanks to looking into this. Given that there is no offsetof marco defined in grub (although it is not difficult to define one) and also it is common to use pointer math to calculate the size/offset in many different places. I'd pick this way as the whole point here is just to get the offset to be read from disk thus the operation that index into array members is undue here.
And after I encountered more errors from gcc-10 ...
*sigh*
Good news is that I seems to figure out the reason, and am working on the patch. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189#c10
--- Comment #10 from Michael Chang
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189#c11
pgnd _
... I will fix that and repost patches. ...
iiuc, gcc10 @ obs is not (?) yet patched? -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189#c13
--- Comment #13 from Martin Liška
(In reply to pgnd _ from comment #11)
are the patches _here_ already the ones you referenced here, same or newer?:
Upstream is newer.
iiuc, gcc10 @ obs is not (?) yet patched?
They are going to be submitted soon. Please be patient. :)
Hey. Any update please? -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189
http://bugzilla.opensuse.org/show_bug.cgi?id=1158189#c14
--- Comment #14 from pgnd _
Hey. Any update please?
from my end, testing, https://build.opensuse.org/package/show/home:pgnd:test:grub2+gcc10/grub2 with my gcc build, from home:pgnd:devel:gcc10 , which is currently gcc --version gcc (SUSE Linux) 10.0.1 20200406 (experimental) [revision c72a1b6f8b26de37d1a922a8af143af009747498] still fails, https://build.opensuse.org/package/live_build_log/home:pgnd:test:grub2+gcc10... -- You are receiving this mail because: You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com