<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Multiple races reported in std::async (TSan)"
href="https://llvm.org/bugs/show_bug.cgi?id=23235">23235</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Multiple races reported in std::async (TSan)
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>oleg@smolsky.net
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=14204" name="attach_14204" title="TSan output">attachment 14204</a> <a href="attachment.cgi?id=14204&action=edit" title="TSan output">[details]</a></span>
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;
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>