[Bug sanitizer/69204] New: ThreadSanitizer: False positive on std::promise usage
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69204 Bug ID: 69204 Summary: ThreadSanitizer: False positive on std::promise usage Product: gcc Version: 5.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: bugzil...@reto-schneider.ch CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org Target Milestone: --- When compiling the following code with GCC 5.3.1 (or 5.2.1) and having the thread sanitizer enabled, a false positive gets reported by TSan. Code: #include #include #include #include int main() { std::promise p; auto f = std::async(std::launch::async, [&] { p.set_value(); }); p.get_future().wait(); std::cout << "Done!\n"; return 0; } Command: g++-5 -fsanitize=thread -Wall -Wextra -std=c++11 -pthread -static-libtsan tsan-test.cpp && ./a.out Expected: Done! Actual: ...many lines of stacktraces... SUMMARY: ThreadSanitizer: data race ??:0 std::unique_ptr::get() const == Done! ThreadSanitizer: reported 1 warnings In my understanding, this code is absolutely correct and Clang 3.6 does also not see any issues with it. Compiler: $ g++-5 -v Using built-in specs. COLLECT_GCC=g++-5 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.2.1-22ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2)
[Bug sanitizer/69204] ThreadSanitizer: False positive on std::promise usage
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69204 --- Comment #1 from bugzil...@reto-schneider.ch --- Created attachment 37285 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37285&action=edit Preprocessed source Preprocessed test case. Compressed due to the 1MB limit.
[Bug sanitizer/69204] ThreadSanitizer: False positive on std::promise usage
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69204 --- Comment #2 from bugzil...@reto-schneider.ch --- Created attachment 37286 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37286&action=edit Minimal example
[Bug sanitizer/69204] ThreadSanitizer: False positive on std::promise usage
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69204 --- Comment #4 from bugzil...@reto-schneider.ch --- Created attachment 37295 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37295&action=edit g++-5 -fsanitize=thread -Wall -Wextra -std=c++11 -pthread -static-libtsan tsan-test.cpp && ./a.out > sanitizer-output.txt 2>&1 Output of the program
[Bug sanitizer/69204] ThreadSanitizer: False positive on std::promise usage
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69204 --- Comment #5 from bugzil...@reto-schneider.ch --- The generated binaries use the same libraries: $ clang++-3.6 -fsanitize=thread -Wall -Wextra -std=c++11 -pthread -o tsan-test-clang tsan-test.cpp $ ldd tsan-test-clang linux-vdso.so.1 (0x7fff1d397000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x7fcf82df) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x7fcf82aeb000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x7fcf828cd000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x7fcf826c5000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x7fcf824c1000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x7fcf822aa000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x7fcf81f06000) /lib64/ld-linux-x86-64.so.2 (0x55e4931e1000) $ g++-5 -fsanitize=thread -Wall -Wextra -std=c++11 -pthread -static-libtsan -o tsan-test-gcc tsan-test.cpp $ ldd tsan-test-gcc linux-vdso.so.1 (0x7ffc8a382000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x7fa9b9778000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x7fa9b9473000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x7fa9b9255000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x7fa9b9051000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x7fa9b8e3b000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x7fa9b8a96000) /lib64/ld-linux-x86-64.so.2 (0x564f3130c000)
[Bug sanitizer/69204] ThreadSanitizer: False positive on std::promise usage
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69204 --- Comment #7 from bugzil...@reto-schneider.ch --- I did some bisecting. r219770 is the commit which breaks my example.
[Bug sanitizer/69204] ThreadSanitizer: False positive on std::promise usage
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69204 --- Comment #8 from bugzil...@reto-schneider.ch --- (In reply to bugzillas from comment #7) > I did some bisecting. r219770 is the commit which breaks my example. ...or just exposes an already existing failure.
[Bug sanitizer/69204] ThreadSanitizer: False positive on std::promise usage
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69204 --- Comment #10 from bugzil...@reto-schneider.ch --- Which is a known limitation or something that can/will be fixed?