On x86_64, for which clear_cache is a no-op, I see the 'test-cache' test fail.

How to reproduce:
$ rm -rf ../testdir1; ./gnulib-tool --create-testdir --dir=../testdir1 
--single-configure jit/cache
$ cd ../testdir1
Use clang 17 with ASAN and UBSAN:
$ export CC="$clang17dir/bin/clang -Wl,-rpath,$clang17dir/lib 
-fsanitize=address,undefined,signed-integer-overflow,shift,integer-divide-by-zero"
$ export CFLAGS="-O0 -fno-omit-frame-pointer -ggdb"
$ export ASAN_OPTIONS="detect_leaks=0 abort_on_error=1 
allocator_may_return_null=1"
$ ./configure
$ make
$ cd gltests
$ make check
...
../../build-aux/test-driver: line 112: 2414596 Aborted                 (core 
dumped) "$@" >> "$log_file" 2>&1
FAIL: test-cache
...

But when I run test-cache alone, it succeeds:

$ make check TESTS="test-cache"
PASS: test-cache

$ ./test-cache; echo $?
0

The really strange thing is that when run in a sequence of ca. 65 or more tests,
it fails. Whereas in a sequence of 62 more fewer tests, it succeeds.
For example, changing gltests/Makefile to contain this:

TESTS = test-asyncsafe-spin1$(EXEEXT) test-asyncsafe-spin2$(EXEEXT) \
        test-binary-io.sh test-bind$(EXEEXT) test-c-ctype$(EXEEXT) \
        test-calloc-gnu$(EXEEXT) test-cloexec$(EXEEXT) \
        test-close$(EXEEXT) test-connect$(EXEEXT) test-ctype$(EXEEXT) \
        test-dup2$(EXEEXT) test-environ$(EXEEXT) test-errno$(EXEEXT) \
        test-error.sh test-fcntl-h$(EXEEXT) test-fcntl$(EXEEXT) \
        test-fdopen$(EXEEXT) test-fgetc$(EXEEXT) test-float$(EXEEXT) \
        test-fputc$(EXEEXT) test-fread$(EXEEXT) test-free$(EXEEXT) \
        test-fstat$(EXEEXT) test-ftruncate.sh test-fwrite$(EXEEXT) \
        test-getcwd-lgpl$(EXEEXT) test-getdtablesize$(EXEEXT) \
        test-getprogname$(EXEEXT) test-gettimeofday$(EXEEXT) \
        test-ignore-value$(EXEEXT) test-inet_pton$(EXEEXT) \
        test-intprops$(EXEEXT) test-inttypes$(EXEEXT) \
        test-ioctl$(EXEEXT) test-isblank$(EXEEXT) \
        test-isnand-nolibm$(EXEEXT) test-isnanf-nolibm$(EXEEXT) \
        test-isnanl-nolibm$(EXEEXT) test-cache$(EXEEXT) \
        test-largefile$(EXEEXT) test-limits-h$(EXEEXT) \
        test-linkedhash_list$(EXEEXT) test-listen$(EXEEXT) \
        test-rwlock1$(EXEEXT) test-lock$(EXEEXT) test-once1$(EXEEXT) \
        test-once2$(EXEEXT) test-lstat$(EXEEXT) \
        test-malloc-gnu$(EXEEXT) test-malloca$(EXEEXT) \
        test-math$(EXEEXT) test-nanosleep$(EXEEXT) \
        test-netinet_in$(EXEEXT) test-open$(EXEEXT) \
        test-pathmax$(EXEEXT) test-perror.sh test-perror2$(EXEEXT) \
        test-pipe$(EXEEXT) test-pselect$(EXEEXT) test-pthread$(EXEEXT) \
        test-pthread-thread$(EXEEXT) test-pthread_sigmask1$(EXEEXT) \
        test-pthread_sigmask2$(EXEEXT) test-raise$(EXEEXT)

"make check" fails:
# TOTAL: 64
# PASS:  63
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

$ cat test-cache.log
AddressSanitizer:DEADLYSIGNAL
=================================================================
==2453430==ERROR: AddressSanitizer: SEGV on unknown address 0x7fe78b24cff8 (pc 
0x557b10fbfa02 bp 0x7fff2fbb4590 sp 0x7fff2fbb4440 T0)
==2453430==The signal is caused by a READ memory access.
    #0 0x557b10fbfa02 in main /GNULIB/testdir1/gltests/jit/test-cache.c:348:3
    #1 0x7fe78b61bd8f in __libc_start_call_main 
csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #2 0x7fe78b61be3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #3 0x557b10ee5344 in _start (/GNULIB/testdir1/gltests/test-cache+0x2c344)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /GNULIB/testdir1/gltests/jit/test-cache.c:348:3 
in main
==2453430==ABORTING
FAIL test-cache (exit status: 134)


Whereas with just two tests removed (from the end!):

TESTS = test-asyncsafe-spin1$(EXEEXT) test-asyncsafe-spin2$(EXEEXT) \
        test-binary-io.sh test-bind$(EXEEXT) test-c-ctype$(EXEEXT) \
        test-calloc-gnu$(EXEEXT) test-cloexec$(EXEEXT) \
        test-close$(EXEEXT) test-connect$(EXEEXT) test-ctype$(EXEEXT) \
        test-dup2$(EXEEXT) test-environ$(EXEEXT) test-errno$(EXEEXT) \
        test-error.sh test-fcntl-h$(EXEEXT) test-fcntl$(EXEEXT) \
        test-fdopen$(EXEEXT) test-fgetc$(EXEEXT) test-float$(EXEEXT) \
        test-fputc$(EXEEXT) test-fread$(EXEEXT) test-free$(EXEEXT) \
        test-fstat$(EXEEXT) test-ftruncate.sh test-fwrite$(EXEEXT) \
        test-getcwd-lgpl$(EXEEXT) test-getdtablesize$(EXEEXT) \
        test-getprogname$(EXEEXT) test-gettimeofday$(EXEEXT) \
        test-ignore-value$(EXEEXT) test-inet_pton$(EXEEXT) \
        test-intprops$(EXEEXT) test-inttypes$(EXEEXT) \
        test-ioctl$(EXEEXT) test-isblank$(EXEEXT) \
        test-isnand-nolibm$(EXEEXT) test-isnanf-nolibm$(EXEEXT) \
        test-isnanl-nolibm$(EXEEXT) test-cache$(EXEEXT) \
        test-largefile$(EXEEXT) test-limits-h$(EXEEXT) \
        test-linkedhash_list$(EXEEXT) test-listen$(EXEEXT) \
        test-rwlock1$(EXEEXT) test-lock$(EXEEXT) test-once1$(EXEEXT) \
        test-once2$(EXEEXT) test-lstat$(EXEEXT) \
        test-malloc-gnu$(EXEEXT) test-malloca$(EXEEXT) \
        test-math$(EXEEXT) test-nanosleep$(EXEEXT) \
        test-netinet_in$(EXEEXT) test-open$(EXEEXT) \
        test-pathmax$(EXEEXT) test-perror.sh test-perror2$(EXEEXT) \
        test-pipe$(EXEEXT) test-pselect$(EXEEXT) test-pthread$(EXEEXT) \
        test-pthread-thread$(EXEEXT) test-pthread_sigmask1$(EXEEXT)

"make check" succeeds:
# TOTAL: 62
# PASS:  62
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0

It looks like when 'make' prepares to run more than 64 tests in sequence
(not in parallel!), it makes side effects somewhere that cause the ASAN to
report a SEGV for a call instruction into return1_code.

This is with GNU make 4.3.

Btw, changing 
unsigned char const return1_code[] = { 0xb8,0x01,0x00,0x00,0x00, 0xc3 };
unsigned char const return2_code[] = { 0xb8,0x02,0x00,0x00,0x00, 0xc3 };
to
unsigned char const return1_code[] = { 0xf3,0x0f,0x1e,0xfa, 
0xb8,0x01,0x00,0x00,0x00, 0xc3 };
unsigned char const return2_code[] = { 0xf3,0x0f,0x1e,0xfa, 
0xb8,0x02,0x00,0x00,0x00, 0xc3 };
(with an 'endbr64' at the beginning) does not help.

Paul and Paul, you know the job control engine of GNU make well. Any idea?

Bruno




Reply via email to