Use pseudo-random rand() instead of cryptographically secure random numbers #3152
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.
Some AMD CPUs seems to return a non-random number, but still claim success. This makes
random_device
throw an exception, which is passed to the host application, which then crashes.To work around this, simply use pseudo-random numbers.
Fixes #3151 and probably sass/node-sass#3047
This is a simplistic fix, but is tested to work and fix the problem on a CPU where it was broken before. I can surely imagine more elaborate fixes, e.g. to use
random_device
first, catch the exception, and userand()
only as fallback.However, I do wonder why libsass is using cryptographically secure random numbers in the first place, and what for. I don't see why CSS would need that. I would think that pseudo-random is sufficient. So, maybe this is even the right fix, as-is.
I am contributing the fix that I found. If you would like to improve this, please go ahead. My involvement stops here. My objectively was merely to continue to use the host application, which suddenly failed on the new computer. I hope to help others who run into the same problem.