public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.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 11:51:58 +0000	[thread overview]
Message-ID: <bug-94087-4-z6VfSxzDYH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94087-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94087

--- Comment #20 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 14 May 2020, redi at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94087
> 
> --- Comment #19 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> If you mean the mersenne twister in the std::random_device object, that's a
> union member and doesn't exist when a proper source (/dev/random, rdrand,
> rdseed etc) is available. So we'd need to add *another* mersenne twister object
> (which would double the size of std::random_device, changing ABI, or have to be
> global and protected by a mutex, or thread-local) and we'd have to seed it so
> it's not 100% deterministic, and MT has a state size of 19968 bits which needs
> a lot of seeding. It's not a good choice for many reasons.

Doh.  OK, guess I'd set up the twister in all cases and make it 
programatically skip itself when rdrand/rdseed is available so we
could easily fall back to it.  Not sure what extra state there is
that warrants the union, but well ... I suppose simply calling
random() from the C library isn't an option ;)

  parent reply	other threads:[~2020-05-14 11:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-08  2:51 [Bug libstdc++/94087] New: " coryan+gccbugzilla at google dot com
2020-03-08  7:51 ` [Bug target/94087] " pinskia at gcc dot gnu.org
2020-03-08  7:51 ` pinskia at gcc dot gnu.org
2020-03-08  8:08 ` pinskia at gcc dot gnu.org
2020-03-08 12:04 ` coryan+gccbugzilla at google dot com
2020-03-08 12:09 ` coryan+gccbugzilla at google dot com
2020-03-09  9:44 ` redi at gcc dot gnu.org
2020-03-09 12:10 ` coryan+gccbugzilla at google dot com
2020-03-09 12:24 ` redi at gcc dot gnu.org
2020-04-23  3:30 ` wnereiz at kawashiro dot org
2020-05-14 10:27 ` rguenth at gcc dot gnu.org
2020-05-14 10:30 ` rguenth at gcc dot gnu.org
2020-05-14 10:44 ` redi at gcc dot gnu.org
2020-05-14 10:51 ` redi at gcc dot gnu.org
2020-05-14 11:35 ` redi at gcc dot gnu.org
2020-05-14 11:35 ` hjl.tools at gmail dot com
2020-05-14 11:37 ` rguenther at suse dot de
2020-05-14 11:38 ` rguenther at suse dot de
2020-05-14 11:41 ` rguenther at suse dot de
2020-05-14 11:46 ` redi at gcc dot gnu.org
2020-05-14 11:51 ` rguenther at suse dot de [this message]
2020-05-14 12:01 ` redi at gcc dot gnu.org
2020-05-14 12:02 ` redi at gcc dot gnu.org
2020-05-14 12:05 ` redi at gcc dot gnu.org
2020-05-19 22:23 ` cvs-commit at gcc dot gnu.org
2020-05-23  8:18 ` redi at gcc dot gnu.org
2020-07-09  8:49 ` avi@cloudius-systems.com
2020-07-09  9:14 ` cvs-commit at gcc dot gnu.org
2020-07-09  9:14 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-94087-4-z6VfSxzDYH@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).