>Since 0.15.0, we've introduce an annotation layer (not part of the
>public API), making TSAN compatible with URCU. See
>`include/urcu/annotate.h' and the `CMM_SANITIZE_THREAD' macro.
>
>However, IIRC, you also need to compile URCU with the configuration
>option `--enable-compiler-atomic-builtins' so that atomic operations are
>implemented with the configured toolchain's builtin atomics. I don't
>recall if this was strictly necessary.
>
>If you encounter false positives with TSAN, please send me a minimal
>reproducible example together with:
>
> - the toolchain you’re using
>
> - the version of URCU
>
> - the configuration flags you used
>
>I will be happy to have a look.
Sorry for the late answer. I had to find the time to fix some bugs to get it all running before switching to urcu v0.15.0 and setting the flags and macros for thread sanitizer support. Creating a minimum reproducible example would take some time as I don't have any good idea of the exact place where the thread sanitizer issues arise because they are scattered all over tsm.c and test_tsm.c. If you have linux debian family then you can clone my repo and run it:
https://github.com/ThobiasKnudsen/Logos. ./scripts/build.sh --debug --tsan && ./build/bin/test_tsm. I tried running with and without thread sanitizer support and got the same issues. In the test_tsm when only one thread is running, the thread sanitizer produces warnings still. I did find a place where the thread sanitizer said there was a race and the write was within a node not yet inserted into the cds_lfht. That seems like a false positive. The read for the same case should be inside rcu_read_lock as everything within lines 263 to 904 inside test_tsm.c is within a read section.
Read of size 1 at 0x7b1400085ea1 by thread T6:
#0 tsm_base_node_is_valid /Logos/src/tsm.c:721 (test_tsm+0xa548)
#1 _tsm_tsm_type_is_valid /Logos/src/tsm.c:364 (test_tsm+0xb1bf)
#2 tsm_node_is_valid /Logos/src/tsm.c:1553 (test_tsm+0x9984)
#3 tsm_node_defer_free /Logos/src/tsm.c:1888 (test_tsm+0xb2fc)
#4 stress_thread /Logos/src/tests/test_tsm.c:549 (test_tsm+0x46a6)
Previous write of size 1 at 0x7b1400085ea1 by thread T9:
#0 tsm_base_node_create /Logos/src/tsm.c:683 (test_tsm+0x6f2a)
#1 stress_thread /Logos/src/tests/test_tsm.c:843 (test_tsm+0x5ce0)
>I don’t see why that would be a problem for the static-check algorithm I
>described above. If a pointer needs to be protected by a mutex for
>mutation, that falls outside the scope of RCU, as far as I know.
If I understand correctly the __rcu checks that reads are not done outside read sections and unsafe writes are not done at all. If this is correct then if you are using custom concurrency for __rcu protected data outside the read section or unsafe writes is that allowed? Because if it's not that would be a limitation for __rcu.