]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Don't compile read1.so with -fsanitize
authorTom de Vries <tdevries@suse.de>
Wed, 30 Apr 2025 11:56:19 +0000 (13:56 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 30 Apr 2025 11:56:19 +0000 (13:56 +0200)
After building gdb with:
...
CFLAGS= -O0 -g -fstack-protector-all -fsanitize=thread -fno-exceptions
CXXFLAGS= -O0 -g -fstack-protector-all -fsanitize=thread
...
when doing:
...
$ cd build/gdb
$ make check-read1 RUNTESTFLAGS=gdb.threads/clone-attach-detach.exp
...
I run into:
...
Running /data/vries/gdb/src/gdb/testsuite/gdb.threads/clone-attach-detach.exp ...
ThreadSanitizer:DEADLYSIGNAL
==4799==ERROR: ThreadSanitizer: SEGV on unknown address 0x000000000000 \
  (pc 0x7f636029a947 bp 0x7f635dfbf090 sp 0x7f635dfbf028 T4824)
==4799==The signal is caused by a READ memory access.
==4799==Hint: address points to the zero page.
ThreadSanitizer:DEADLYSIGNAL
ThreadSanitizer: nested bug in the same thread, aborting.
...

This doesn't happen when doing the same from build/gdb/testsuite, because
CFLAGS doesn't get propagated from build/gdb.

I'm not sure what is the root cause here, but when building with
-fsanitize, I'm interested in running the sanitizer on gdb, not on testsuite
utility libraries that are used with expect.

Fix this by skipping -fsanitize when compiling read1.so and readmore.so.

Tested on x86_64-linux, by rebuilding read1.so and running the test-case.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/Makefile.in

index 0d5ad908f52fd81640e833296b6ba8562fdec4fd..4a6665d4483c1f8b5726722ef90ef9d558c59610 100644 (file)
@@ -440,14 +440,15 @@ expect-read1 expect-readmore:
 # function, making it read one byte at a time.  Running the testsuite
 # with this catches racy tests.
 read1.so: lib/read1.c
-       $(ECHO_CC) $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC $(CFLAGS)
+       $(ECHO_CC) $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC \
+         $(filter-out -fsanitize=%,$(CFLAGS))
 
 # Build the readmore.so preload library.  This overrides the `read'
 # function, making it try harder to read more at a time.  Running the
 # testsuite with this catches racy tests.
 readmore.so: lib/read1.c
        $(ECHO_CC) $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC \
-         $(CFLAGS) -DREADMORE
+         $(filter-out -fsanitize=%,$(CFLAGS)) -DREADMORE
 
 # Build the read1 machinery.
 .PHONY: read1 readmore