This repository has been archived by the owner on Dec 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
fix: workaround a libstdc++ on random_device #208
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On fairly recent versions of libstdc++ the `std::random_device` class fails when used by multiple threads: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94087 We workaround this problem by detecting the version of the standard C++ library, and if it is `libstdc++` and it is a version after 20200128 then we use `rdrand` as the token value to initialize `std::random_device`, which does not have the problem with multiple threads.
googlebot
added
the
cla: yes
This human has signed the Contributor License Agreement.
label
Mar 8, 2020
Codecov Report
@@ Coverage Diff @@
## master #208 +/- ##
==========================================
+ Coverage 96.26% 96.28% +0.01%
==========================================
Files 97 97
Lines 4421 4443 +22
==========================================
+ Hits 4256 4278 +22
Misses 165 165
Continue to review full report at Codecov.
|
devbww
reviewed
Mar 8, 2020
PTAL |
devbww
approved these changes
Mar 8, 2020
devbww
approved these changes
Mar 9, 2020
This was referenced Apr 1, 2020
coryan
added a commit
that referenced
this pull request
Apr 1, 2020
The workaround put in place in #208 does not work with g++-9.3.1 on Fedora:31. Despite this being a "newer" version of libstdc++, it does not support `rdrand` as a token for `std::random_device` maybe because the CPU specific tokens are not enabled. For now, use `/dev/urandom` which seems to be supported on all Linux distros. On other platforms we continue to use the default constructor for `std::random_device`. It might be possible to refine this and detect, at run-time, if `rdrand` is supported, but that seems like an improvement that can wait a little bit.
coryan
added a commit
to coryan/google-cloud-cpp
that referenced
this pull request
Apr 24, 2020
…-cpp-common#208) On fairly recent versions of libstdc++ the `std::random_device` class fails when used by multiple threads: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94087 We workaround this problem by detecting the version of the standard C++ library, and if it is `libstdc++` and it is a version after 20200128 then we use `rdrand` as the token value to initialize `std::random_device`, which does not have the problem with multiple threads.
coryan
added a commit
to coryan/google-cloud-cpp
that referenced
this pull request
Apr 24, 2020
…-cloud-cpp-common#272) The workaround put in place in googleapis/google-cloud-cpp-common#208 does not work with g++-9.3.1 on Fedora:31. Despite this being a "newer" version of libstdc++, it does not support `rdrand` as a token for `std::random_device` maybe because the CPU specific tokens are not enabled. For now, use `/dev/urandom` which seems to be supported on all Linux distros. On other platforms we continue to use the default constructor for `std::random_device`. It might be possible to refine this and detect, at run-time, if `rdrand` is supported, but that seems like an improvement that can wait a little bit.
coryan
added a commit
to coryan/google-cloud-cpp
that referenced
this pull request
Apr 24, 2020
…-cpp-common#208) On fairly recent versions of libstdc++ the `std::random_device` class fails when used by multiple threads: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94087 We workaround this problem by detecting the version of the standard C++ library, and if it is `libstdc++` and it is a version after 20200128 then we use `rdrand` as the token value to initialize `std::random_device`, which does not have the problem with multiple threads.
coryan
added a commit
to coryan/google-cloud-cpp
that referenced
this pull request
Apr 24, 2020
…-cloud-cpp-common#272) The workaround put in place in googleapis/google-cloud-cpp-common#208 does not work with g++-9.3.1 on Fedora:31. Despite this being a "newer" version of libstdc++, it does not support `rdrand` as a token for `std::random_device` maybe because the CPU specific tokens are not enabled. For now, use `/dev/urandom` which seems to be supported on all Linux distros. On other platforms we continue to use the default constructor for `std::random_device`. It might be possible to refine this and detect, at run-time, if `rdrand` is supported, but that seems like an improvement that can wait a little bit.
coryan
added a commit
to coryan/google-cloud-cpp
that referenced
this pull request
Apr 24, 2020
…-cpp-common#208) On fairly recent versions of libstdc++ the `std::random_device` class fails when used by multiple threads: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94087 We workaround this problem by detecting the version of the standard C++ library, and if it is `libstdc++` and it is a version after 20200128 then we use `rdrand` as the token value to initialize `std::random_device`, which does not have the problem with multiple threads.
coryan
added a commit
to coryan/google-cloud-cpp
that referenced
this pull request
Apr 24, 2020
…-cloud-cpp-common#272) The workaround put in place in googleapis/google-cloud-cpp-common#208 does not work with g++-9.3.1 on Fedora:31. Despite this being a "newer" version of libstdc++, it does not support `rdrand` as a token for `std::random_device` maybe because the CPU specific tokens are not enabled. For now, use `/dev/urandom` which seems to be supported on all Linux distros. On other platforms we continue to use the default constructor for `std::random_device`. It might be possible to refine this and detect, at run-time, if `rdrand` is supported, but that seems like an improvement that can wait a little bit.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On fairly recent versions of libstdc++ the
std::random_device
classfails when used by multiple threads:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94087
We workaround this problem by detecting the version of the standard C++
library, and if it is
libstdc++
and it is a version after 20200128then we use
rdrand
as the token value to initializestd::random_device
, which does not have the problem with multiplethreads.
Part of the work for googleapis/google-cloud-cpp#3437
This change is