From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2F8D63840C1A; Thu, 14 May 2020 10:27:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F8D63840C1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589452057; bh=eY8eo0hXIg7siMiXbgtWcrH3vGPnlwNnTwHvzlRdpcE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=S3rj1/SRRU77gBvznPcz47RUMM8BIsZRqfFcSmQ/OevkVXHP7AJLiSBZiloowtehU JKdaDAu/+GMOsEekYDFTm8V+c9g7IKQIKI02P90i3agR+HSKVnlpGcXzlzdrloOON1 we2OSBwMAAwKN5NVHeLaoGSuk2A/EzxKiQJ1Ufic= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/94087] std::random_device often fails when used from multiple threads Date: Thu, 14 May 2020 10:27:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 9.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed bug_status cf_reconfirmed_on Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 May 2020 10:27:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94087 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2020-05-14 --- Comment #10 from Richard Biener --- So it looks like the rdseed usage is new in GCC 10 libstdc++ and it prevails over the previous rdrand support if supported on your CPU. I can reproduce this on a CPU with rdseed support and libstdc++ from GCC 10. The code invoked looks correct to me: 20: 83 e8 01 sub $0x1,%eax 23: 74 12 je 37 <_ZNSt12_GLOBAL__N_112__x86_rdseedEPv+ 0x37> 25: f3 90 pause=20=20 27: 0f c7 fa rdseed %edx 2a: 89 11 mov %edx,(%rcx) 2c: 73 f2 jae 20 <_ZNSt12_GLOBAL__N_112__x86_rdseedEPv+ 0x20> the number of tries libstdc++ does is 100. Note rdrand doesn't exhibit this issue. So it might very well be a hardware limitation. Btw, the reproducer can be "enhanced" by providing the method of operation: std::random_device rd("rdseed"); that makes sure it will fail in a different way on a not capable CPU (Intel Broadwell or later or AMD Zen).=