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
os.urandom(2500) fails on Solaris 11.3 #70922
Comments
On Solaris 11.3 (intel tested, but I assume issue is on SPARC as well), The above throws OSError: [Errno 22] Invalid argument. It turns out that the Solaris version of getrandom() is limited to returning EINVAL The flags are not set to GRND_RANDOM, GRND_NONBLOCK or both, I've attached a possible patch for this issue, against the 3.5.1 source |
See also the issue bpo-25003 and the changeset 835085cc28cd: Issue bpo-25003: On Solaris 11.3 or newer, os.urandom() now uses the getrandom() function instead of the getentropy() function. The getentropy() function is blocking to generate very good quality entropy, os.urandom() doesn't need such high-quality entropy. |
I guess that you are already using Python 3.5.1 which uses getrandom(). You should try to confirm using strace. I updated your patch. I replaced "#if defined(sun)" with "#ifdef sun", since "#ifdef sun" looks more common in the Python code base, and I never saw "#if defined(sun)" in the Python code base. I also avoided the new len variable, I reused the n variable. I don't have Solaris, so I cannot test. I didn't find getrandom() manual page neither, I only found this blog post which doesn't mention the 1024 bytes limitation on Solaris: |
The new patch looks fine; I used __sun__ rather than sun out of habit I found the original problem through debugging with GDB, so I know Oddly, the blog post you linked to describes getrandom as: But no such limit current exists in the Linux version that I can see; On Tue, Apr 12, 2016 at 1:15 AM, STINNER Victor <report@bugs.python.org> wrote:
|
Do you mean that it fixes your issue? Can it be applied to Python 3.5 & 3.6? |
Yes, I've verified that:
|
New changeset fb7628e8dfef by Victor Stinner in branch '3.5': |
Cool, thanks for the bug report and for the check. It's now fixed. In the meanwhile, you can workaround the issue by limiting yourself calls to os.urandom() to 1024 bytes (and then concatenate the result). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: