QEMU Eoan FTBS in my machine (gcc9 + amd related ?)

Bug #1841457 reported by Rafael David Tinoco
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
qemu (Ubuntu)
Won't Fix
High
Unassigned

Bug Description

Some Eoan GCC (9) errors in my environment:

----
In file included from /usr/include/string.h:494,
                 from /home/inaddy/work/sources/ubuntu/qemu/include/qemu/osdep.h:101,
                 from /home/inaddy/work/sources/ubuntu/qemu/util/qemu-sockets.c:18:
In function ‘strncpy’,
    inlined from ‘unix_connect_saddr.isra.0’ at /home/inaddy/work/sources/ubuntu/qemu/util/qemu-sockets.c:925:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Werror=stringop-truncation]
  106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘unix_listen_saddr.isra.0’ at /home/inaddy/work/sources/ubuntu/qemu/util/qemu-sockets.c:880:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Werror=stringop-truncation]
  106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
----

Fixed (and tested) by upstream commit:

commit 2d2023c3b99edb33ad4bb9791f70456ea1a1c049
Author: Daniel P. Berrangé <email address hidden>
Date: Wed May 1 11:50:52 2019

    sockets: avoid string truncation warnings when copying UNIX path

----
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c: In function ‘init_qxl_ram’:
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:50:19: error: taking address of packed member of ‘struct QXLReleaseRing_ring_el’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
   50 | ret = &(r)->items[prod].el; \
      | ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:429:5: note: in expansion of macro ‘SPICE_RING_PROD_ITEM’
  429 | SPICE_RING_PROD_ITEM(d, &d->ram->release_ring, item);
      | ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c: In function ‘qxl_push_free_res’:
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:50:19: error: taking address of packed member of ‘struct QXLReleaseRing_ring_el’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
   50 | ret = &(r)->items[prod].el; \
      | ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:762:5: note: in expansion of macro ‘SPICE_RING_PROD_ITEM’
  762 | SPICE_RING_PROD_ITEM(d, ring, item);
      | ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c: In function ‘interface_release_resource’:
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:50:19: error: taking address of packed member of ‘struct QXLReleaseRing_ring_el’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
   50 | ret = &(r)->items[prod].el; \
      | ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:795:5: note: in expansion of macro ‘SPICE_RING_PROD_ITEM’
  795 | SPICE_RING_PROD_ITEM(qxl, ring, item);
----

Fixed (and tested) by upstream commit:

commit 94932c95c10400acd286fd768a6b411e7ebbec8f
Author: Daniel P. Berrangé <email address hidden>
Date: Fri Apr 12 09:16:26 2019

    qxl: avoid unaligned pointer reads/writes

----

/home/inaddy/work/sources/ubuntu/qemu/hw/usb/hcd-xhci.c: In function ‘usb_xhci_realize’:
/home/inaddy/work/sources/ubuntu/qemu/hw/usb/hcd-xhci.c:3339:66: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 5 [-Werror=format-truncation=]
 3339 | snprintf(port->name, sizeof(port->name), "usb2 port #%d", i+1);
      | ^~
/home/inaddy/work/sources/ubuntu/qemu/hw/usb/hcd-xhci.c:3339:54: note: directive argument in the range [1, 2147483647]
 3339 | snprintf(port->name, sizeof(port->name), "usb2 port #%d", i+1);
      | ^~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:867,
                 from /home/inaddy/work/sources/ubuntu/qemu/include/qemu/osdep.h:99,
                 from /home/inaddy/work/sources/ubuntu/qemu/hw/usb/hcd-xhci.c:21:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 13 and 22 bytes into a destination of size 16
   67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 | __bos (__s), __fmt, __va_arg_pack ());

----

Fixed (and tested) by upstream commit:

commit ccb799313a5926a6aa49018bbc67fe6165fad7f3
Author: Daniel P. Berrangé <email address hidden>
Date: Fri Apr 12 09:16:25 2019

    hw/usb: avoid format truncation warning when formatting port name

----

/home/inaddy/work/sources/ubuntu/qemu/hw/usb/dev-mtp.c: In function ‘usb_mtp_write_metadata’:
/home/inaddy/work/sources/ubuntu/qemu/hw/usb/dev-mtp.c:1715:36: error: taking address of packed member of ‘struct <anonymous>’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
 1715 | dataset->filename);

----

Fixed (and tested) by upstream commit:

commit 1259f27ec2113d34e54ee731aac5990d9606d9fa
Author: Daniel P. Berrangé <email address hidden>
Date: Mon Apr 15 12:45:03 2019

    usb-mtp: fix alignment of access of ObjectInfo filename field

----

In function ‘strncpy’,
    inlined from ‘fill_psinfo’ at /home/inaddy/work/sources/ubuntu/qemu/linux-user/elfload.c:3208:12,
    inlined from ‘fill_note_info’ at /home/inaddy/work/sources/ubuntu/qemu/linux-user/elfload.c:3390:5,
    inlined from ‘elf_core_dump’ at /home/inaddy/work/sources/ubuntu/qemu/linux-user/elfload.c:3539:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Werror=stringop-truncation]
  106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

----

Fixed (and tested) by upstream commit:

commit d7eb2b928a855a2e8038e8e75f7edf1a12226bd3
Author: Alistair Francis <email address hidden>
Date: Tue Apr 30 20:29:01 2019

    linux-user/elfload: Fix GCC 9 build warnings

----

/home/inaddy/work/sources/ubuntu/qemu/roms/SLOF/lib/libnet/icmpv6.c: In function ‘handle_ra’:
/home/inaddy/work/sources/ubuntu/qemu/roms/SLOF/lib/libnet/icmpv6.c:171:11: error: taking address of packed member of ‘struct ip6hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
  171 | rtr_ip = (ip6_addr_t *) &ip6h->src;
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/roms/SLOF/lib/libnet/icmpv6.c:173:21: error: taking address of packed member of ‘struct ip6hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
  173 | rtr = find_router (&(ip6h->src));
      | ^~~~~~~~~~~~

----

Need fix in:
https://github.com/qemu/SLOF

continues...

Changed in qemu (Ubuntu):
status: New → Confirmed
importance: Undecided → High
description: updated
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

FOUND THE ISSUE!

Whenever compiling from a git (or git-ubuntu) repository:

----

./configure:

....

1868 # Consult white-list to determine whether to enable werror
1869 # by default. Only enable by default for git builds
1870 if test -z "$werror" ; then
1871 if test -e "$source_path/.git" && \
1872 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1873 werror="yes"
1874 else
1875 werror="no"
1876 fi
1877 fi

....

# Now we've finished running tests it's OK to add -Werror to the compiler flags
if test "$werror" = "yes"; then
    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
fi

and then config.log:

QEMU_CFLAGS -I/usr/include/pixman-1 -Werror -DHAS_LIBSSH2_SFTP_FSYNC -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -std=gnu99 -g -O0 -fdebug-prefix-map=/home/inaddy/work/sources/ubuntu/qemu=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -Wexpansion-to-defined

----

Werror will be configured by default in QEMU_CFLAGS (independently of dpkg-buildflags).

To avoid that we could use:

   --disable-werror disable compilation abort on warning

But not exactly sure why this is happening now since the configure changes are old.

Removing the .git directory I got:

QEMU_CFLAGS -I/usr/include/pixman-1 -DHAS_LIBSSH2_SFTP_FSYNC -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -std=gnu99 -g -O0 -fdebug-prefix-map=/home/inaddy/work/sources/ubuntu/qemu=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -Wexpansion-to-defined -Wendif-labels -Wno-shift-negative-value -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-strong -I/usr/include/p11-kit-1 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/capstone

like expected. (No -Werror flag).

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

There are multiple building issues solved by multiple upstream patches, as demonstrated in this bug description. I was interested in why Werror was turned into default in my environment and comment #1 explains the cause (despite the building errors that could/should be fixed as well).

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

(errors/warnings, but, still, could/should be fixed).

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks for the details Rafael.
Interesting that the mode changes with .git; but I don't think we need/want to fix that right now being so busy as it doesn't fail the normal build for Eoan.

Maybe if it was an LTS (and for sure if the Eoan build on LP Infra would be affected).
But without that I'd mark it won't fix for now.

Changed in qemu (Ubuntu):
status: Confirmed → Won't Fix
Revision history for this message
Marietto (marietto2008) wrote :
Download full text (3.5 KiB)

why won't fix ? It seems that I found the same error :

gcc -Wno-error -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-deprecated-declarations -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-deprecated-declarations -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MF .install.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-deprecated-declarations -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MF .subdirs-install.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-deprecated-declarations -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MF .subdir-install-xenpmd.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-deprecated-declarations -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MF .xenpmd.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Werror -I/etc/xen/igvtg-xen/tools/xenpmd/../../tools/xenstore/include -I/etc/xen/igvtg-xen/tools/xenpmd/../../tools/include -c -o xenpmd.o xenpmd.c
In file included from /usr/include/string.h:495,
                 from xenpmd.c:37:
In function ‘strncpy’,
    inlined from ‘set_attribute_battery_info.part.0’ at xenpmd.c:207:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 32 equals destination size [-Werror=stringop-truncation]
  106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘set_attribute_battery_info.part.0’ at xenpmd.c:201:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 32 equals destination size [-Werror=stringop-truncation]
  106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘set_attribute_battery_info.part.0’ at xenpmd.c:195:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 32 equals destination size [-Werror=stringop-truncation]
  106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘set_attribute_battery...

Read more...

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

@Marietto,

Bug description contains:

" Fixed (and tested) by upstream commit "

If you search for that string you will find all upstream commits I was pointing out to @paelzer, Ubuntu qemu maintainer, when we were at Eoan development cycle (we are in Groovy development cycle now and this does not make more sense as we are not facing FTBFS for previous releases).

The real issue, pointed out in comment #1, was driven by @ddstreet recently in bug:

https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1887823

but, a TL;DR for you is "remove .git directory from the source directory when building", or .. read comment #1.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.