From: Tom de Vries Date: Wed, 30 Apr 2025 11:56:19 +0000 (+0200) Subject: [gdb/testsuite] Don't compile read1.so with -fsanitize X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0ecc474b769473cb0b402e6a1e1d9788f9d538ac;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Don't compile read1.so with -fsanitize 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 --- diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in index 0d5ad908f52..4a6665d4483 100644 --- a/gdb/testsuite/Makefile.in +++ b/gdb/testsuite/Makefile.in @@ -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