-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: Make g_insecure_rand_ctx thread_local #14953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This seems overkill, as most tests are single-threaded. The multi-threaded test could just have one RNG per thread? By that I mean having an explicit "FastRandomContext rng(true);" in each of the threads. |
|
The alternative you suggest (only give each thread their own randomness context when they are multithreaded) would involve (re)writing the |
|
Oh, I forgot about the wrappers for the global test RNG. Objection withdrawn. |
|
utACK |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
faead93 test: Make g_insecure_rand_ctx thread_local (MarcoFalke) Pull request description: Some tests might spin up several threads and `FastRandomContext` is not thread safe. Fix that by giving each thread their own randomness context (as opposed to e.g. making `FastRandomContext` thread safe or add locks elsewhere). Also, add the `g_` prefix to it (according to developer notes), since I am touching it anyway. Tree-SHA512: c6b61375636dfbb2f8311efe8b47e9fe7c4f8bee9804871243f877545f3117cb6aa8556a2d9b1d1673e46e2e585b695a8ddd235b746b583c3eab962435efe2d1
|
No idea if this is significant, but mentioning just in case: Thread-local support used to be optional before this (was only used in sync.h in debug mode optionally). This change ignores |
|
Should those tests perhaps fail explicitly, like in Or should we make it mandatory in Some earlier related discussion:
We bumped the requirement from @theuni wrote there:
From Apple docs: "Xcode 8.1 requires a Mac running macOS 10.11.5 or later". We still support macOS 10.10. We could consider bumping that to 10.11.5, or accept that some tests won't run.
So perhaps this depends on if we drop e.g. Ubuntu Trusty 14.04 in the next release. |
|
|
|
@MarcoFalke That reasoning seems backwards. We identify what C++ version (and features) we can use based on the platforms we want to support. I don't mean to say that this particular change is a problem, but just because we're considering C++14 does not mean we should drop support for every platform that doesn't support every feature from C++11 or C++14. Does this mean we have now removed support for OSX 10.10 for the unit tests with this change? |
|
It would be easier to decide which C++11 (or C++14) features are acceptable to use when there was a guideline/process that defines compatibility requirements we want to achieve. |
It's probably a bit of both. It's easier to support older platforms if it only causes minor inconveniences. This change indeed breaks macOS 10.10 support for the unit tests. Afaik it takes a patch with an |
fa61202 test: Add comment to g_insecure_rand_ctx (MarcoFalke) fa0d3c4 test: Undo thread_local g_insecure_rand_ctx (MarcoFalke) Pull request description: `thread_local` seems to be highly controversial according to the discussion in #14953, so remove it again from the tests. Also remove boost::thread_group in the test that uses it, since I am touching it anyway. Tree-SHA512: 977c1f597e3cfbd0e97d0b037d998fdbc701f62e9a2f57e02dbe1727b63ae8ff478dbd9d3d6dc4ffdfa23f2058b331f04949d51f23a8f55b41ecb75f088f1cbe
zcash: cherry picked from commit faead93 zcash: bitcoin/bitcoin#14953
zcash: cherry picked from commit faead93 zcash: bitcoin/bitcoin#14953
faead93 test: Make g_insecure_rand_ctx thread_local (MarcoFalke) Pull request description: Some tests might spin up several threads and `FastRandomContext` is not thread safe. Fix that by giving each thread their own randomness context (as opposed to e.g. making `FastRandomContext` thread safe or add locks elsewhere). Also, add the `g_` prefix to it (according to developer notes), since I am touching it anyway. Tree-SHA512: c6b61375636dfbb2f8311efe8b47e9fe7c4f8bee9804871243f877545f3117cb6aa8556a2d9b1d1673e46e2e585b695a8ddd235b746b583c3eab962435efe2d1
fa61202 test: Add comment to g_insecure_rand_ctx (MarcoFalke) fa0d3c4 test: Undo thread_local g_insecure_rand_ctx (MarcoFalke) Pull request description: `thread_local` seems to be highly controversial according to the discussion in bitcoin#14953, so remove it again from the tests. Also remove boost::thread_group in the test that uses it, since I am touching it anyway. Tree-SHA512: 977c1f597e3cfbd0e97d0b037d998fdbc701f62e9a2f57e02dbe1727b63ae8ff478dbd9d3d6dc4ffdfa23f2058b331f04949d51f23a8f55b41ecb75f088f1cbe
fa61202 test: Add comment to g_insecure_rand_ctx (MarcoFalke) fa0d3c4 test: Undo thread_local g_insecure_rand_ctx (MarcoFalke) Pull request description: `thread_local` seems to be highly controversial according to the discussion in bitcoin#14953, so remove it again from the tests. Also remove boost::thread_group in the test that uses it, since I am touching it anyway. Tree-SHA512: 977c1f597e3cfbd0e97d0b037d998fdbc701f62e9a2f57e02dbe1727b63ae8ff478dbd9d3d6dc4ffdfa23f2058b331f04949d51f23a8f55b41ecb75f088f1cbe
Some tests might spin up several threads and
FastRandomContextis not thread safe.Fix that by giving each thread their own randomness context (as opposed to e.g. making
FastRandomContextthread safe or add locks elsewhere).Also, add the
g_prefix to it (according to developer notes), since I am touching it anyway.