[llvm-bugs] [Bug 52509] New: ThreadSanitizer: data race in std::__1::ios_base::width()
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Nov 15 06:14:42 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=52509
Bug ID: 52509
Summary: ThreadSanitizer: data race in
std::__1::ios_base::width()
Product: libc++
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: maic23 at live.de
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
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>
>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*,
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>
>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)
<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>
>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*,
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>
>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)
<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>
>(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char
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>
>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*,
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>
>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)
<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>
>(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char
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>
>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*,
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>
>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)
<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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211115/5e1879a3/attachment.html>
More information about the llvm-bugs
mailing list