openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.52k stars 1.74k forks source link

Error building master on F38: null format string #14809

Open dioni21 opened 1 year ago

dioni21 commented 1 year ago

System information

Type Version/Name
Distribution Name Fedora
Distribution Version 38
Kernel Version 6.2.11-300.fc38.x86_64
Architecture x86_64
OpenZFS Version zfs-2.1.99-1899_g62cc9d4f6

Describe the problem you're observing

Cannot compile OpenZFS in FC38

Describe how to reproduce the problem

git checkout master
git pull
git clean -dfx
git reset --hard
./autogen.sh
./configure --enable-silent-rules --enable-dependency-tracking --config-cache --enable-linux-builtin --disable-nls --with-config=all --enable-asan --enable-ubsan --enable-debuginfo --enable-debug --enable-debug-kmem --enable-debug-kmem-tracking CFLAGS=-Wno-stringop-overflow
make -j 12 rpm-utils
...
  CC       cmd/zstream/zstream_decompress.o
  CC       cmd/zstream/zstream_dump.o
  CC       cmd/zstream/zstream_recompress.o
In file included from /usr/include/stdio.h:906,
                 from ./lib/libspl/include/assert.h:32,
                 from cmd/zfs/zfs_main.c:36:
In function ‘fprintf’,
    inlined from ‘usage’ at cmd/zfs/zfs_main.c:539:10:
/usr/include/bits/stdio2.h:79:10: error: null format string [-Werror=format-overflow=]
   79 |   return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   80 |                         __va_arg_pack ());
      |                         ~~~~~~~~~~~~~~~~~
/usr/include/bits/stdio2.h:79:10: error: null format string [-Werror=format-overflow=]
In function ‘fprintf’,
    inlined from ‘usage’ at cmd/zfs/zfs_main.c:524:10:
/usr/include/bits/stdio2.h:79:10: error: null format string [-Werror=format-overflow=]
   79 |   return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   80 |                         __va_arg_pack ());
      |                         ~~~~~~~~~~~~~~~~~
/usr/include/bits/stdio2.h:79:10: error: null format string [-Werror=format-overflow=]
In function ‘fprintf’,
    inlined from ‘usage’ at cmd/zfs/zfs_main.c:603:10:
/usr/include/bits/stdio2.h:79:10: error: null format string [-Werror=format-overflow=]
   79 |   return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   80 |                         __va_arg_pack ());
      |                         ~~~~~~~~~~~~~~~~~
...
  CCLD     tests/zfs-tests/cmd/mmap_sync
cc1: all warnings being treated as errors
  CCLD     tests/zfs-tests/cmd/mmapwrite
  CCLD     tests/zfs-tests/cmd/readmmap
make[4]: *** [Makefile:8530: cmd/zfs/zfs_main.o] Error 1
make[4]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[4]: *** [Makefile:11157: cmd/zpool/zpool-zpool_main.o] Error 1
make[4]: Leaving directory '/tmp/zfs-build-root-NTdnXFVT/BUILD/zfs-2.1.99'
make[3]: *** [Makefile:12073: all-recursive] Error 1
make[3]: Leaving directory '/tmp/zfs-build-root-NTdnXFVT/BUILD/zfs-2.1.99'
make[2]: *** [Makefile:4592: all] Error 2
make[2]: Leaving directory '/tmp/zfs-build-root-NTdnXFVT/BUILD/zfs-2.1.99'
error: Bad exit status from /tmp/zfs-build-root-NTdnXFVT/TMP/rpm-tmp.4tOUv1 (%build)

RPM build warnings:
    source_date_epoch_from_changelog set but %changelog is missing

RPM build errors:
...

Include any warning/errors/backtraces from the system logs

BTW: I can avoid this error by disabling -Werror before build:

sed -i '/ DEBUG_CFLAGS="-Werror"/s/^/#/' config/zfs-build.m4

Not sure if this is safe, though...

Edit: current commit is 5a83f761c7c7445dda39d3fd3c5aa2a7bcb353f1 but this has been happening for some time now.

mjguzik commented 1 year ago

That's one low value error, alas

diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index e28f1d04f..667eaebd1 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -536,7 +536,7 @@ usage(boolean_t requested)
                (void) fprintf(fp, gettext("\nEach dataset is of the form: "
                    "pool/[dataset/]*dataset[@name]\n"));
        } else {
-               (void) fprintf(fp, gettext("usage:\n"));
+               (void) fprintf(fp, "%s", gettext("usage:\n"));
                (void) fprintf(fp, "%s", get_usage(current_command->usage));
        }

does this do the trick?

dioni21 commented 1 year ago

This would do, but I just printed the first error, it was not the only one... 😢

And apparently it was not the fault of some OpenBSD commit, but some recent upgrade to gcc on FC38. Now on gcc-13.1.1-1.fc38.x86_64.

mjguzik commented 1 year ago

ye i suspect there are more crappers of the sort. this is all trivial and frankly low value and preferably avoided, but it will likely keep popping up so probably should be fixed after all. that said, since you have a build env which repreduces, how about you patch it out? :)

tonyhutter commented 1 year ago

@dioni21 maybe we're doing things slightly differently, but I cannot reproduce this on F38. When I build with your ./configure line, I get this failure:

checking whether gcc supports -fsanitize=undefined... configure: error: gcc does not support -fsanitize=undefined

This is due to --enable-ubsan. If I take that out, it builds:

$ ./autogen.sh
$ ./configure --enable-silent-rules --enable-dependency-tracking --config-cache --enable-linux-builtin --disable-nls --with-config=all --enable-asan --enable-debuginfo --enable-debug --enable-debug-kmem --enable-debug-kmem-tracking CFLAGS=-Wno-stringop-overflow
$ make -j 12 rpm-utils
...
    absolute symlink: /etc/zfs/zpool.d/test_type -> /usr/libexec/zfs/zpool.d/test_type
    absolute symlink: /etc/zfs/zpool.d/upath -> /usr/libexec/zfs/zpool.d/upath
    absolute symlink: /etc/zfs/zpool.d/vendor -> /usr/libexec/zfs/zpool.d/vendor
    absolute symlink: /etc/zfs/zpool.d/w_proc -> /usr/libexec/zfs/zpool.d/w_proc
    absolute symlink: /etc/zfs/zpool.d/w_ucor -> /usr/libexec/zfs/zpool.d/w_ucor
    File listed twice: /sbin/zgenhostid
    File listed twice: /usr/lib/.build-id/e5/af478f0bcc1e7c1e6bff8c15da149dfe34e2b5
    absolute symlink: /usr/lib/systemd/system/zfs-import.service -> /dev/null
    absolute symlink: /usr/lib/systemd/system/zfs-load-key.service -> /dev/null
make[1]: Leaving directory '/home/hutter/zfs'
tonyhutter commented 11 months ago

configure: error: gcc does not support -fsanitize=undefined

Note to self - this can be fixed with dnf install libubsan

tonyhutter commented 11 months ago

I'm seeing a lot of these errors building on Fedora 39.