This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Don't run tsan tests if a trivial test doesn't work


On Fri, 31 Jan 2014, Jakub Jelinek wrote:

> On Fri, Jan 31, 2014 at 12:34:46PM +0100, Jakub Jelinek wrote:
> > Apparently tsan doesn't work e.g. under setarch x86_64 -R, at which point
> > all tests fail.  This patch just disables the tests in that case.
> > 
> > Tested on x86_64-linux both under setarch x86_64 -R and without, committed
> > to trunk as obvious.
> > 
> > Of course it would be nicer if libtsan actually supported that (and didn't
> > rely on PIEs etc.), but I don't see that as a priority for upstream :(.
> > 
> > 2014-01-31  Jakub Jelinek  <jakub@redhat.com>
> > 
> > 	* lib/tsan-dg.exp (tsan_init): Try to run a trivial program,
> > 	if it fails don't run any tsan tests.
> 
> As discussed on IRC, some people would like to have tsan tests at least
> as compile tests if they can't be reliably executed.
> 
> So, this patch implements that by tweaking dg-do-what default.
> 
> Ok for trunk?

Ok (you remove one target selector - was that spurious)

Thanks,
Richard.

> 2014-01-31  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR sanitizer/59410
> 	* lib/tsan-dg.exp (tsan_init): Instead of not running any
> 	tsan tests if trivial testcase doesn't run, set dg-do-what-default
> 	to compile.
> 	(tsan_finish): Restore dg-do-what-default.
> 	* g++.dg/tsan/atomic_free.C: Remove dg-do line.
> 	* g++.dg/tsan/fd_close_norace2.C: Likewise.
> 	* g++.dg/tsan/default_options.C: Likewise.
> 	* g++.dg/tsan/aligned_vs_unaligned_race.C: Likewise.
> 	* g++.dg/tsan/atomic_free2.C: Likewise.
> 	* g++.dg/tsan/cond_race.C: Likewise.
> 	* g++.dg/tsan/fd_close_norace.C: Likewise.
> 	* g++.dg/tsan/benign_race.C: Likewise.
> 	* c-c++-common/tsan/fd_pipe_race.c: Likewise.
> 	* c-c++-common/tsan/simple_race.c: Likewise.
> 	* c-c++-common/tsan/mutexset1.c: Likewise.
> 	* c-c++-common/tsan/thread_leak2.c: Likewise.
> 	* c-c++-common/tsan/tls_race.c: Likewise.
> 	* c-c++-common/tsan/write_in_reader_lock.c: Likewise.
> 	* c-c++-common/tsan/race_on_barrier2.c: Likewise.
> 	* c-c++-common/tsan/free_race2.c: Likewise.
> 	* c-c++-common/tsan/thread_leak.c: Likewise.
> 	* c-c++-common/tsan/thread_leak1.c: Likewise.
> 	* c-c++-common/tsan/race_on_barrier.c: Likewise.
> 	* c-c++-common/tsan/free_race.c: Likewise.
> 	* c-c++-common/tsan/sleep_sync.c: Likewise.
> 	* c-c++-common/tsan/tiny_race.c: Likewise.
> 	* c-c++-common/tsan/race_on_mutex2.c: Likewise.
> 	* c-c++-common/tsan/atomic_stack.c: Likewise.
> 	* c-c++-common/tsan/race_on_mutex.c: Likewise.  Adjust line numbers
> 	in dg-output regexps.
> 	* c-c++-common/tsan/simple_stack.c: Likewise.
> 
> --- gcc/testsuite/lib/tsan-dg.exp.jj	2014-01-31 12:30:09.000000000 +0100
> +++ gcc/testsuite/lib/tsan-dg.exp	2014-01-31 13:21:26.350586160 +0100
> @@ -69,6 +69,8 @@ proc tsan_init { args } {
>      global ALWAYS_CXXFLAGS
>      global TOOL_OPTIONS
>      global tsan_saved_TEST_ALWAYS_FLAGS
> +    global dg-do-what-default
> +    global tsan_saved_dg-do-what-default
>  
>      set link_flags ""
>      if ![is_remote host] {
> @@ -79,6 +81,9 @@ proc tsan_init { args } {
>  	}
>      }
>  
> +    if [info exists dg-do-what-default] {
> +	set tsan_saved-dg-do-what-default dg-do-what-default
> +    }
>      if [info exists TEST_ALWAYS_FLAGS] {
>  	set tsan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
>      }
> @@ -96,8 +101,11 @@ proc tsan_init { args } {
>  	if [check_runtime_nocache tsan_works {
>  		int main () { return 0; }
>  	    } "-fPIE -pie -fsanitize=thread -g"] {
> -	    return 1
> +	    set dg-do-what-default run
> +	} else {
> +	    set dg-do-what-default compile
>  	}
> +	return 1
>      }
>      return 0
>  }
> @@ -109,10 +117,17 @@ proc tsan_init { args } {
>  proc tsan_finish { args } {
>      global TEST_ALWAYS_FLAGS
>      global tsan_saved_TEST_ALWAYS_FLAGS
> +    global dg-do-what-default
> +    global tsan_saved_dg-do-what-default
>  
>      if [info exists tsan_saved_TEST_ALWAYS_FLAGS] {
>  	set TEST_ALWAYS_FLAGS $tsan_saved_TEST_ALWAYS_FLAGS
>      } else {
>  	unset TEST_ALWAYS_FLAGS
>      }
> +    if [info exists tsan_saved-dg-do-what-default] {
> +	set dg-do-what-default tsan_saved-dg-do-what-default
> +    } else {
> +	unset dg-do-what-default
> +    }
>  }
> --- gcc/testsuite/g++.dg/tsan/atomic_free.C.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/g++.dg/tsan/atomic_free.C	2014-01-31 13:15:25.110473518 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/g++.dg/tsan/fd_close_norace2.C.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/g++.dg/tsan/fd_close_norace2.C	2014-01-31 13:15:30.882443238 +0100
> @@ -1,5 +1,3 @@
> -/* { dg-do run } */
> -
>  #include <pthread.h>
>  #include <stdio.h>
>  #include <unistd.h>
> --- gcc/testsuite/g++.dg/tsan/default_options.C.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/g++.dg/tsan/default_options.C	2014-01-31 13:15:29.373451426 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/g++.dg/tsan/aligned_vs_unaligned_race.C.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/g++.dg/tsan/aligned_vs_unaligned_race.C	2014-01-31 13:15:21.715491311 +0100
> @@ -1,5 +1,3 @@
> -/* { dg-do run { target { x86_64-*-linux* } } } */
> -
>  #include <pthread.h>
>  #include <stdio.h>
>  #include <stdint.h>
> --- gcc/testsuite/g++.dg/tsan/atomic_free2.C.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/g++.dg/tsan/atomic_free2.C	2014-01-31 13:15:24.118477957 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/g++.dg/tsan/cond_race.C.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/g++.dg/tsan/cond_race.C	2014-01-31 13:15:28.313457024 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  /* { dg-output "ThreadSanitizer: data race.*" } */
>  /* { dg-output "pthread_cond_signal.*" } */
> --- gcc/testsuite/g++.dg/tsan/fd_close_norace.C.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/g++.dg/tsan/fd_close_norace.C	2014-01-31 13:15:32.161436934 +0100
> @@ -1,5 +1,3 @@
> -/* { dg-do run } */
> -
>  #include <pthread.h>
>  #include <stdio.h>
>  #include <unistd.h>
> --- gcc/testsuite/g++.dg/tsan/benign_race.C.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/g++.dg/tsan/benign_race.C	2014-01-31 13:15:26.669466015 +0100
> @@ -1,5 +1,3 @@
> -/* { dg-do run } */
> -
>  #include <pthread.h>
>  #include <stdio.h>
>  #include <unistd.h>
> --- gcc/testsuite/c-c++-common/tsan/fd_pipe_race.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/fd_pipe_race.c	2014-01-31 13:14:16.592830286 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/simple_race.c.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/simple_race.c	2014-01-31 13:14:25.721782330 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/mutexset1.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/mutexset1.c	2014-01-31 13:14:19.871812854 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/thread_leak2.c.jj	2013-12-10 12:42:58.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/thread_leak2.c	2014-01-31 13:14:30.747757548 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/tls_race.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/tls_race.c	2014-01-31 13:14:40.407704833 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/write_in_reader_lock.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/write_in_reader_lock.c	2014-01-31 13:14:41.539701455 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/race_on_barrier2.c.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/race_on_barrier2.c	2014-01-31 13:14:20.940807662 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/free_race2.c.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/free_race2.c	2014-01-31 13:14:17.627824972 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <stdlib.h>
> --- gcc/testsuite/c-c++-common/tsan/thread_leak.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/thread_leak.c	2014-01-31 13:14:38.159718310 +0100
> @@ -1,5 +1,3 @@
> -/* { dg-do run } */
> -
>  #include <pthread.h>
>  #include <stdio.h>
>  
> --- gcc/testsuite/c-c++-common/tsan/thread_leak1.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/thread_leak1.c	2014-01-31 13:14:29.326763932 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/race_on_barrier.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/race_on_barrier.c	2014-01-31 13:14:22.035801741 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/free_race.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/free_race.c	2014-01-31 13:14:18.806818672 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <stdlib.h>
> --- gcc/testsuite/c-c++-common/tsan/sleep_sync.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/sleep_sync.c	2014-01-31 13:14:28.143769095 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/tiny_race.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/tiny_race.c	2014-01-31 13:14:39.237712295 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/race_on_mutex2.c.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/race_on_mutex2.c	2014-01-31 13:14:23.193795850 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/atomic_stack.c.jj	2013-12-05 20:08:00.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/atomic_stack.c	2014-01-31 13:14:15.566833470 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> --- gcc/testsuite/c-c++-common/tsan/race_on_mutex.c.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/race_on_mutex.c	2014-01-31 13:38:35.207264575 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> @@ -38,7 +37,7 @@ int main() {
>  /* { dg-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r)" } */
>  /* { dg-output "  Atomic read of size 1 at .* by thread T2:(\n|\r\n|\r)" } */
>  /* { dg-output "    #0 pthread_mutex_lock.*" } */
> -/* { dg-output "    #1 Thread2.* .*(race_on_mutex.c:22|\\?{2}:0) (.*)" } */
> +/* { dg-output "    #1 Thread2.* .*(race_on_mutex.c:21|\\?{2}:0) (.*)" } */
>  /* { dg-output "  Previous write of size 1 at .* by thread T1:(\n|\r\n|\r)" } */
>  /* { dg-output "    #0 pthread_mutex_init .* (.)*" } */
> -/* { dg-output "    #1 Thread1.* .*(race_on_mutex.c:13|\\?{2}:0) .*" } */
> +/* { dg-output "    #1 Thread1.* .*(race_on_mutex.c:12|\\?{2}:0) .*" } */
> --- gcc/testsuite/c-c++-common/tsan/simple_stack.c.jj	2013-12-12 14:28:31.000000000 +0100
> +++ gcc/testsuite/c-c++-common/tsan/simple_stack.c	2014-01-31 13:39:04.698115731 +0100
> @@ -1,4 +1,3 @@
> -/* { dg-do run } */
>  /* { dg-shouldfail "tsan" } */
>  
>  #include <pthread.h>
> @@ -51,16 +50,16 @@ int main() {
>  
>  /* { dg-output "WARNING: ThreadSanitizer: data race.*" } */
>  /* { dg-output "  Write of size 4 at .* by thread T1:(\n|\r\n|\r)" } */
> -/* { dg-output "    #0 foo1.* .*(simple_stack.c:11|\\?{2}:0) (.*)" } */
> -/* { dg-output "    #1 bar1.* .*(simple_stack.c:16|\\?{2}:0) (.*)" } */
> -/* { dg-output "    #2 Thread1.* .*(simple_stack.c:30|\\?{2}:0) (.*)" } */
> +/* { dg-output "    #0 foo1.* .*(simple_stack.c:10|\\?{2}:0) (.*)" } */
> +/* { dg-output "    #1 bar1.* .*(simple_stack.c:15|\\?{2}:0) (.*)" } */
> +/* { dg-output "    #2 Thread1.* .*(simple_stack.c:29|\\?{2}:0) (.*)" } */
>  /* { dg-output "  Previous read of size 4 at .* by thread T2:(\n|\r\n|\r)" } */
> -/* { dg-output "    #0 foo2.* .*(simple_stack.c:20|\\?{2}:0) (.*)" } */
> -/* { dg-output "    #1 bar2.* .*(simple_stack.c:25|\\?{2}:0) (.*)" } */
> -/* { dg-output "    #2 Thread2.* .*(simple_stack.c:35|\\?{2}:0) (.*)" } */
> +/* { dg-output "    #0 foo2.* .*(simple_stack.c:19|\\?{2}:0) (.*)" } */
> +/* { dg-output "    #1 bar2.* .*(simple_stack.c:24|\\?{2}:0) (.*)" } */
> +/* { dg-output "    #2 Thread2.* .*(simple_stack.c:34|\\?{2}:0) (.*)" } */
>  /* { dg-output "  Thread T1 \\(tid=.*, running\\) created by main thread at:(\n|\r\n|\r)" } */
>  /* { dg-output "    #0 pthread_create .* (.*)" } */
> -/* { dg-output "    #1 StartThread.* .*(simple_stack.c:40|\\?{2}:0) (.*)" } */
> +/* { dg-output "    #1 StartThread.* .*(simple_stack.c:39|\\?{2}:0) (.*)" } */
>  /* { dg-output "  Thread T2 (.*) created by main thread at:(\n|\r\n|\r)" } */
>  /* { dg-output "    #0 pthread_create .* (.*)" } */
> -/* { dg-output "    #1 StartThread.* .*(simple_stack.c:40|\\?{2}:0) (.*)" } */
> +/* { dg-output "    #1 StartThread.* .*(simple_stack.c:39|\\?{2}:0) (.*)" } */
> 
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]