<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - ThreadSanitizer: data race in std::__1::ios_base::width()"
href="https://bugs.llvm.org/show_bug.cgi?id=52509">52509</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ThreadSanitizer: data race in std::__1::ios_base::width()
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</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>maic23@live.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>I can reproduce with all versions of clang.
Steps to reproduce:
$ cat 1.cpp && clang++ -stdlib=libc++ -fsanitize=thread -std=c++20 1.cpp &&
./a.out
#include <iostream>
#include <thread>
void Print() { std::cout << ""; }
int main() {
std::thread a{Print};
std::thread b{Print};
a.join();
b.join();
}
==================
WARNING: ThreadSanitizer: data race (pid=4144)
Read of size 4 at 0x000000500d28 by thread T2:
#0 std::__1::basic_ios<char, std::__1::char_traits<char> >::fill() const
<null> (a.out+0x4c301c)
#1 std::__1::basic_ostream<char, std::__1::char_traits<char> >&
std::__1::__put_character_sequence<char, std::__1::char_traits<char>
<span class="quote">>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*,</span >
unsigned long) <null> (a.out+0x4c2956)
#2 std::__1::basic_ostream<char, std::__1::char_traits<char> >&
std::__1::operator<<<std::__1::char_traits<char>
<span class="quote">>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)</span >
<null> (a.out+0x4c256d)
#3 Print() <null> (a.out+0x4c240f)
#4 decltype(static_cast<void (*>(fp)()) std::__1::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0x4c46d2)
#5 void
std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void
(*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&,
std::__1::__tuple_indices<>) <null> (a.out+0x4c4615)
#6 void*
std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*)
<null> (a.out+0x4c3cd2)
Previous write of size 4 at 0x000000500d28 by thread T1:
#0 std::__1::basic_ios<char, std::__1::char_traits<char> >::fill() const
<null> (a.out+0x4c306a)
#1 std::__1::basic_ostream<char, std::__1::char_traits<char> >&
std::__1::__put_character_sequence<char, std::__1::char_traits<char>
<span class="quote">>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*,</span >
unsigned long) <null> (a.out+0x4c2956)
#2 std::__1::basic_ostream<char, std::__1::char_traits<char> >&
std::__1::operator<<<std::__1::char_traits<char>
<span class="quote">>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)</span >
<null> (a.out+0x4c256d)
#3 Print() <null> (a.out+0x4c240f)
#4 decltype(static_cast<void (*>(fp)()) std::__1::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0x4c46d2)
#5 void
std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void
(*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&,
std::__1::__tuple_indices<>) <null> (a.out+0x4c4615)
#6 void*
std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*)
<null> (a.out+0x4c3cd2)
Location is global 'std::__1::cout' of size 160 at 0x000000500c90
(a.out+0x000000500d28)
Thread T2 (tid=4147, running) created by main thread at:
#0 pthread_create <null> (a.out+0x44c6cd)
#1 std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*),
void*) <null> (a.out+0x4c3c49)
#2 std::__1::thread::thread<void (&)(), void>(void (&)()) <null>
(a.out+0x4c26b0)
#3 main <null> (a.out+0x4c2471)
Thread T1 (tid=4146, finished) created by main thread at:
#0 pthread_create <null> (a.out+0x44c6cd)
#1 std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*),
void*) <null> (a.out+0x4c3c49)
#2 std::__1::thread::thread<void (&)(), void>(void (&)()) <null>
(a.out+0x4c26b0)
#3 main <null> (a.out+0x4c245e)
SUMMARY: ThreadSanitizer: data race (/a.out+0x4c301c) in
std::__1::basic_ios<char, std::__1::char_traits<char> >::fill() const
==================
==================
WARNING: ThreadSanitizer: data race (pid=4144)
Read of size 8 at 0x000000500cb0 by thread T2:
#0 std::__1::ios_base::width() const <null> (a.out+0x4c31bd)
#1 std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >
std::__1::__pad_and_output<char, std::__1::char_traits<char>
<span class="quote">>(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char</span >
const*, char const*, char const*, std::__1::ios_base&, char) <null>
(a.out+0x4c2c83)
#2 std::__1::basic_ostream<char, std::__1::char_traits<char> >&
std::__1::__put_character_sequence<char, std::__1::char_traits<char>
<span class="quote">>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*,</span >
unsigned long) <null> (a.out+0x4c298d)
#3 std::__1::basic_ostream<char, std::__1::char_traits<char> >&
std::__1::operator<<<std::__1::char_traits<char>
<span class="quote">>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)</span >
<null> (a.out+0x4c256d)
#4 Print() <null> (a.out+0x4c240f)
#5 decltype(static_cast<void (*>(fp)()) std::__1::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0x4c46d2)
#6 void
std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void
(*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&,
std::__1::__tuple_indices<>) <null> (a.out+0x4c4615)
#7 void*
std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*)
<null> (a.out+0x4c3cd2)
Previous write of size 8 at 0x000000500cb0 by thread T1:
#0 std::__1::ios_base::width(long) <null> (a.out+0x4c33b6)
#1 std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >
std::__1::__pad_and_output<char, std::__1::char_traits<char>
<span class="quote">>(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char</span >
const*, char const*, char const*, std::__1::ios_base&, char) <null>
(a.out+0x4c2e65)
#2 std::__1::basic_ostream<char, std::__1::char_traits<char> >&
std::__1::__put_character_sequence<char, std::__1::char_traits<char>
<span class="quote">>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*,</span >
unsigned long) <null> (a.out+0x4c298d)
#3 std::__1::basic_ostream<char, std::__1::char_traits<char> >&
std::__1::operator<<<std::__1::char_traits<char>
<span class="quote">>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)</span >
<null> (a.out+0x4c256d)
#4 Print() <null> (a.out+0x4c240f)
#5 decltype(static_cast<void (*>(fp)()) std::__1::__invoke<void (*)()>(void
(*&&)()) <null> (a.out+0x4c46d2)
#6 void
std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void
(*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&,
std::__1::__tuple_indices<>) <null> (a.out+0x4c4615)
#7 void*
std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*)
<null> (a.out+0x4c3cd2)
Location is global 'std::__1::cout' of size 160 at 0x000000500c90
(a.out+0x000000500cb0)
Thread T2 (tid=4147, running) created by main thread at:
#0 pthread_create <null> (a.out+0x44c6cd)
#1 std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*),
void*) <null> (a.out+0x4c3c49)
#2 std::__1::thread::thread<void (&)(), void>(void (&)()) <null>
(a.out+0x4c26b0)
#3 main <null> (a.out+0x4c2471)
Thread T1 (tid=4146, finished) created by main thread at:
#0 pthread_create <null> (a.out+0x44c6cd)
#1 std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*),
void*) <null> (a.out+0x4c3c49)
#2 std::__1::thread::thread<void (&)(), void>(void (&)()) <null>
(a.out+0x4c26b0)
#3 main <null> (a.out+0x4c245e)
SUMMARY: ThreadSanitizer: data race (/a.out+0x4c31bd) in
std::__1::ios_base::width() const
==================
ThreadSanitizer: reported 2 warnings</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>