[Bug 282794] TSAN false positive
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 16 Nov 2024 12:03:12 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282794
Bug ID: 282794
Summary: TSAN false positive
Product: Base System
Version: 14.1-RELEASE
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: threads
Assignee: threads@FreeBSD.org
Reporter: pjfloyd@wanadoo.fr
This example contains one genuine thread hazard.
#include <future>
#include <iostream>
int main()
{
char counter = 0;
auto future1 = std::async(std::launch::async, [&]()
{
counter++;
});
auto future2 = std::async(std::launch::async, [&]()
{
return counter;
});
future1.wait();
// Cast to int to print it as a numerical value rather than a character
std::cout << (int)future2.get();
}
(just "clang++ -g -o test test.cpp -pthread" to build it).
As well as the genuine error I also get
WARNING: ThreadSanitizer: data race (pid=77285)
Write of size 8 at 0x000803b17008 by thread T2:
#0 memset
/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87:3
(test1+0x27a626)
#1 __crt_calloc /usr/src/libexec/rtld-elf/rtld_malloc.c:168:3
(libthr.so.3+0x1e4f6)
#2
std::__1::__thread_specific_ptr<std::__1::__thread_struct>::set_pointer(std::__1::__thread_struct*)
/usr/include/c++/v1/__thread/thread.h:111:3 (bt1+0x2dd3b4)
#3 void*
std::__1::__thread_proxy[abi:se180100]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct>>, void
(std::__1::__async_assoc_state<char, std::__1::__async_func<main::$_1>>::*)(),
std::__1::__async_assoc_state<char,
std::__1::__async_func<main::$_1>>*>>(void*)
/usr/include/c++/v1/__thread/thread.h:200:25 (bt1+0x2db9bc)
Previous write of size 8 at 0x000803b17008 by thread T1:
#0 memset
/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87:3
(bt1+0x27a626)
#1 __crt_calloc /usr/src/libexec/rtld-elf/rtld_malloc.c:168:3
(libthr.so.3+0x1e4f6)
#2
std::__1::__thread_specific_ptr<std::__1::__thread_struct>::set_pointer(std::__1::__thread_struct*)
/usr/include/c++/v1/__thread/thread.h:111:3 (bt1+0x2dd3b4)
#3 void*
std::__1::__thread_proxy[abi:se180100]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct>>, void
(std::__1::__async_assoc_state<void, std::__1::__async_func<main::$_0>>::*)(),
std::__1::__async_assoc_state<void,
std::__1::__async_func<main::$_0>>*>>(void*)
/usr/include/c++/v1/__thread/thread.h:200:25 (bt1+0x2d9d4c)
This looks like something during thread startup.
On Linux I only get the one genuine error.
--
You are receiving this mail because:
You are the assignee for the bug.