On Wed, 7 Jan 2015 19:32:16, Jakub Jelinek wrote: >> I am however not sure if I can always use -ldl or have to use some >> target-dependencies here. > > libsanitizer always puts > -lpthread -ldl -lm > into libsanitizer.spec, so I'd say it should be safe and you shouldn't even > need -ldl in dg-additional-options, as merely linking with -fsanitize=thread > should link -ldl in. >
I need -ldl otherwise this happens:
FAIL: g++.dg/tsan/aligned_vs_unaligned_race.C -O0 (test for excess errors)
Excess errors:
/home/ed/gnu/install/x86_64-unknown-linux-gnu/bin/ld: /tmp/ccW6IHbj.o:
undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from
command line
>> --- barrier.h (revision 0)
>> +++ barrier.h (working copy)
>
> I think better to name it tsan_barrier.h or otherwise make it
> clear what this is for.
>
Yes. I'll call it tsan_barrier.h and add a comment.
>> @@ -0,0 +1,12 @@
>> +#include <dlfcn.h>
>> +
>> +static __typeof(pthread_barrier_wait) *barrier_wait;
>> +
>> +static
>> +void barrier_init (pthread_barrier_t *barrier)
>
> And, I'd add unsigned count argument here, and pass it through
> pthread_barrier_init, just in case you need more than 2 threads
> in some test.
>
done.
> Also, what do you need <sched.h> for?
>
Oops ... Thanks for your help.
Here is a new patch, that uses this method on all tsan tests,
which seem to depend on sleep(1), and which have unstable results
because of that.
Successfully tested multiple times with:
make check-gcc-c check-gcc-c++ RUNTESTFLAGS="tsan.exp=*"
OK for trunk?
Thanks
Bernd.
testsuite/ChangeLog: 2015-01-07 Bernd Edlinger <[email protected]> * c-c++-common/tsan/tsan_barrier.h: New. * c-c++-common/tsan/atomic_stack.c: Reworked to not depend on sleep. * c-c++-common/tsan/bitfield_race.c: Likewise. * c-c++-common/tsan/fd_pipe_race.c: Likewise. * c-c++-common/tsan/mutexset1.c: Likewise. * c-c++-common/tsan/race_on_barrier.c: Likewise. * c-c++-common/tsan/race_on_mutex.c: Likewise. * c-c++-common/tsan/race_on_mutex2.c: Likewise. * c-c++-common/tsan/simple_race.c: Likewise. * c-c++-common/tsan/simple_stack.c: Likewise. * c-c++-common/tsan/sleep_sync.c: Likewise. * c-c++-common/tsan/tiny_race.c: Likewise. * c-c++-common/tsan/tls_race.c: Likewise. * c-c++-common/tsan/write_in_reader_lock.c: Likewise. * g++.dg/tsan/aligned_vs_unaligned_race.C: Likewise. * g++.dg/tsan/atomic_free.C: Likewise. * g++.dg/tsan/atomic_free2.C: Likewise. * g++.dg/tsan/cond_race.C: Likewise. * g++.dg/tsan/tsan_barrier.h: Copied from c-c++-common/tsan.
patch-tsan-tests.diff
Description: Binary data
