Bug 1512587

Summary: data race in std::promise/std::future (reported by ThreadSanitizer)
Product: Red Hat Developer Toolset Reporter: Paulo Andrade <pandrade>
Component: gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED ERRATA QA Contact: Michael Petlan <mpetlan>
Severity: medium Docs Contact: Vladimír Slávik <vslavik>
Priority: unspecified    
Version: DTS 6.0 RHEL 6CC: bgollahe, jakub, kanderso, law, mcermak, mnewsome, ohudlick, vslavik
Target Milestone: alpha   
Target Release: 7.1   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: devtoolset-7-gcc-7.2.1-6.el6 Doc Type: Bug Fix
Doc Text:
Previously, the code for the `std::promise` and `std::future` C++ standard library class templates contained a data race. The code has been fixed and the race condition no longer exists.
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-03 05:13:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
racy2.C none

Description Paulo Andrade 2017-11-13 15:26:53 UTC
Created attachment 1351594 [details]
racy2.C

There should be no race (likely a false positive), but libtsan reports
a race.

  Example:

$ scl enable devtoolset-6 bash
$ g++ -fsanitize=thread -static-libtsan -g -o racy racy2.C -lpthread
$ ./racy

  Expected results would be empty output, but actual output
is a report about a race:

[...]
SUMMARY: ThreadSanitizer: data race /opt/rh/devtoolset-6/root/usr/include/c++/6.3.1/bits/unique_ptr.h:308 in std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>::get() const

  The issue also happens in rhel7.

Comment 2 Marek Polacek 2017-12-05 13:51:30 UTC
I could reproduce this with DTS 6, but DTS 7 looks fine:

# g++ --version
g++ (GCC) 7.2.1 20170829 (Red Hat 7.2.1-1)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# g++ -fsanitize=thread -static-libtsan -g -o racy racy.C -lpthread
# ./racy
#

So we should include this BZ in DTS 7.1.

Comment 5 Michael Petlan 2018-04-26 12:07:34 UTC
Successfully reproduced with DTS-6, verified for devtoolset-7-libtsan-devel-7.3.1-5.4.
No races are reported.
VERIFIED.

Comment 8 errata-xmlrpc 2018-05-03 05:13:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:1293