https://llvm.org/bugs/show_bug.cgi?id=23235
Bug ID: 23235
Summary: Multiple races reported in std::async (TSan)
Product: libc++
Version: 3.6
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Created attachment 14204
--> https://llvm.org/bugs/attachment.cgi?id=14204&action=edit
TSan output
I've just noticed TSan warnings when using std::async on Linux. A small example
is below. Compiled with Clang 3.6 and linked against an instrumented version of
libc++:
/opt/clang36/bin/clang++ -std=c++14 -g -fno-omit-frame-pointer
-fsanitize=thread -stdlib=libc++ -fcolor-diagnostics future.cpp -Wl,-rpath
/opt/clang36/lib-tsan -lc++abi -o future
#include <iostream>
#include <memory>
#include <future>
#include <atomic>
std::atomic<int> _counter;
int main()
{
_counter = 1;
auto f = std::async(std::launch::async,
[]{
_counter += 2;
return true;
});
std::cout << "Result: " << std::boolalpha << f.get() << "\n";
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs