#12 Fix test issue with gcc-11
Closed by gonzoleeman. Opened by gonzoleeman.
gonzoleeman/libaio fix-gcc-11-selftest-issue  into  master

Download 12.patch

Test 3.t exercises io_submit() with invalid addresses,
and one test attempted to pass in "-1" as an invalid
pointer. But gcc-11 realizes you cannot take an offset
from an invalid pointer, making it impossible to
compile or run this test:

sh# make CC=gcc-11 partcheck
make[1]: Entering directory '/alt/public_software/libaio/src'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/alt/public_software/libaio/src'
make[1]: Entering directory '/alt/public_software/libaio/harness'
gcc-11 -Wall -Werror -I../src -g -O2 -DTEST_NAME=\"cases/2.t\" -o cases/2.p main.c ../src/libaio.a -lpthread
gcc-11 -Wall -Werror -I../src -g -O2 -DTEST_NAME=\"cases/3.t\" -o cases/3.p main.c ../src/libaio.a -lpthread
In file included from main.c:24:
cases/3.t: In function ‘test_main’:
cases/3.t:18:19: error: ‘attempt_io_submit’ accessing 8 bytes in a region of size 0 [-Werror=stringop-overflow=]
18 | status |= attempt_io_submit( io_ctx, 1, (void )-1, -EFAULT);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cases/3.t:18:19: note: referencing argument 3 of type ‘struct iocb

In file included from cases/3.t:5,
from main.c:24:
cases/aio_setup.h:15:5: note: in a call to function ‘attempt_io_submit’
15 | int attempt_io_submit(io_context_t ctx, long nr, struct iocb
ios[], int expect)
| ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:19: cases/3.p] Error 1
make[1]: Leaving directory '/alt/public_software/libaio/harness'
make: *** [Makefile:23: partcheck] Error 2

The fix is to remove this one test case, since the compiler now
ensures the running code will never see this case.

Signed-off-by: Lee Duncan leeman.duncan@gmail.com

The test is passing that -1 into the kernel system call, and we need to make sure the kernel does the right thing. The right fix would be to disable the stringop-overflow warning. Try adding this to the cflags:

-Wno-stringop-overflow

and see if that allows us to continue to build with -Werror.

Thanks!
Jeff

The test is passing that -1 into the kernel system call, and we need to make sure the kernel does the right thing. The right fix would be to disable the stringop-overflow warning. Try adding this to the cflags:

-Wno-stringop-overflow

and see if that allows us to continue to build with -Werror.

Thanks!
Jeff

Yes, that fixes it. The diff is pretty much:

diff --git a/harness/Makefile b/harness/Makefile
index 5cc2b25d6299..4f225d3ff3bc 100644
--- a/harness/Makefile
+++ b/harness/Makefile
@@ -9,6 +9,11 @@ HARNESS_SRCS:=main.c
 CFLAGS+=-Wall -Werror -I../src -g -O2
 #-lpthread -lrt
+# gcc-11 does not like the test case in 3.t that
+# passes an invalid pointer (-1) to the kernel, so
+# tell the compiler we do not need a warning here
+cases/3.p:     CFLAGS+=-Wno-stringop-overflow
+
 # Change this on the build line to run tests against the installed libraries:
 # make LIBAIO=-laio partcheck
 LIBAIO?=../src/libaio.a

Do you think this should have some sort of if around it in the Makefile? Or should this be good enough? If good enough I can submit another pull request.

no reply here, so I'll cancel this pull request and make a 2nd request, as suggested.

Pull-Request has been closed by gonzoleeman

Metadata