Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure with -Werror=format-overflow in cgroup.c with -O3 #30223

Closed
thesamesam opened this issue Nov 28, 2023 · 2 comments · Fixed by #30224
Closed

Build failure with -Werror=format-overflow in cgroup.c with -O3 #30223

thesamesam opened this issue Nov 28, 2023 · 2 comments · Fixed by #30224
Labels
bug 🐛 Programming errors, that need preferential fixing pid1

Comments

@thesamesam
Copy link
Contributor

systemd version the issue has been seen with

master (78b95cc)

Used distribution

Gentoo

Linux kernel version used

6.6.2

CPU architectures issue was seen on

x86_64

Component

systemd

Expected behaviour you didn't see

Successful build.

Unexpected behaviour you saw

Build failure because of a -Werror=format-overflow warning.

FAILED: src/core/libsystemd-core-255.so.p/cgroup.c.o
ccache cc -Isrc/core/libsystemd-core-255.so.p -Isrc/core -I../src/core -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I. -I.. -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -I/usr/include/blkid -I/usr/include/libmount -I/usr/include/security -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Warray-bounds -Warray-bounds=2 -Wdate-time -Wendif-labels -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=missing-declarations -Werror=missing-prototypes -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=strict-flex-arrays -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wzero-length-bounds -fdiagnostics-show-option -fno-common -fstack-protector -fstack-protector-strong -fstrict-flex-arrays --param=ssp-buffer-size=4 -Wno-maybe-uninitialized -Wno-unused-result -Werror=shadow -O3 -fno-semantic-interposition -fPIC -fno-strict-aliasing -fstrict-flex-arrays=1 -fvisibility=hidden -fno-omit-frame-pointer -include config.h -pthread -fvisibility=default -MD -MQ src/core/libsystemd-core-255.so.p/cgroup.c.o -MF src/core/libsystemd-core-255.so.p/cgroup.c.o.d -o src/core/libsystemd-core-255.so.p/cgroup.c.o -c ../src/core/cgroup.c
../src/core/cgroup.c: In function ‘cgroup_context_dump’:
../src/core/cgroup.c:633:44: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  633 |                         "%sDeviceAllow: %s %s\n",
      |                                            ^~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.

I've hit variants of this a few times, not just with -O3 -fno-semantic-interposition (sometimes just -O3 or even -O2 is enough on alt. arches).

Steps to reproduce the problem

CC=gcc-13 CFLAGS="-O3 -fno-semantic-interposition" meson setup build

Additional program output to the terminal or log subsystem illustrating the issue

No response

@thesamesam thesamesam added the bug 🐛 Programming errors, that need preferential fixing label Nov 28, 2023
@github-actions github-actions bot added the pid1 label Nov 28, 2023
@thesamesam
Copy link
Contributor Author

We hit a another one downstream on s390 with just -O3 in src/shared/install.c (https://bugs.gentoo.org/916518) but with 254.5:

In file included from ../systemd-stable-254.5/src/basic/macro.h:446,
                 from ../systemd-stable-254.5/src/basic/alloc-util.h:10,
                 from ../systemd-stable-254.5/src/shared/install.c:12:
../systemd-stable-254.5/src/shared/install.c: In function ‘install_changes_dump’:
../systemd-stable-254.5/src/shared/install.c:444:64: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  444 |                         err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s does not exist.",

@thesamesam thesamesam changed the title Build failure with -Werror=format-overflow in cgroup.c Build failure with -Werror=format-overflow in cgroup.c with -O3 Nov 28, 2023
yuwata added a commit to yuwata/systemd that referenced this issue Nov 28, 2023
With gcc-13,
```
CFLAGS="-O3 -fno-semantic-interposition" meson setup build
```
triggers the following error:
```
../src/core/cgroup.c: In function ‘cgroup_context_dump’:
../src/core/cgroup.c:633:44: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  633 |                         "%sDeviceAllow: %s %s\n",
      |                                            ^~
cc1: some warnings being treated as errors
```

Fixes systemd#30223.
yuwata added a commit to yuwata/systemd that referenced this issue Nov 28, 2023
With gcc-13,
```
CFLAGS="-O3 -fno-semantic-interposition" meson setup build
```
triggers the following error:
```
../src/core/cgroup.c: In function ‘cgroup_context_dump’:
../src/core/cgroup.c:633:44: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  633 |                         "%sDeviceAllow: %s %s\n",
      |                                            ^~
cc1: some warnings being treated as errors
```

Fixes systemd#30223.
DaanDeMeyer pushed a commit that referenced this issue Nov 28, 2023
With gcc-13,
```
CFLAGS="-O3 -fno-semantic-interposition" meson setup build
```
triggers the following error:
```
../src/core/cgroup.c: In function ‘cgroup_context_dump’:
../src/core/cgroup.c:633:44: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  633 |                         "%sDeviceAllow: %s %s\n",
      |                                            ^~
cc1: some warnings being treated as errors
```

Fixes #30223.
@thesamesam
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Programming errors, that need preferential fixing pid1
Development

Successfully merging a pull request may close this issue.

1 participant