Skip to content
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

getrandom never-ending busy-loop #660

Closed
bagder opened this issue Dec 14, 2023 · 2 comments
Closed

getrandom never-ending busy-loop #660

bagder opened this issue Dec 14, 2023 · 2 comments

Comments

@bagder
Copy link
Member

bagder commented Dec 14, 2023

In this curl issue, someone uses c-ares in a system where getrandom returns -1 with errno set to ENOSYS. It makes c-ares get stuck in a never-ending loop here:

c-ares/src/lib/ares_rand.c

Lines 274 to 282 in 290e9e9

while (1) {
size_t n = len - bytes_read;
/* getrandom() on Linux always succeeds and is never
* interrupted by a signal when requesting <= 256 bytes.
*/
ssize_t rv = getrandom(buf + bytes_read, n > 256 ? 256 : n, 0);
if (rv <= 0) {
continue; /* Just retry. */
}

@bradh352
Copy link
Member

Interesting that the system would have getrandom but the kernel not support it. We can implement a fallback for this case.

bradh352 added a commit that referenced this issue Dec 14, 2023
getrandom() can fail with ENOSYS if the libc supports the function but the kernel does not.

Fixes Bug: #660 
Fix By: Brad House (@bradh352)
@bradh352
Copy link
Member

fixed in #661

bradh352 added a commit that referenced this issue Dec 14, 2023
getrandom() can fail with ENOSYS if the libc supports the function but the kernel does not.

Fixes Bug: #660 
Fix By: Brad House (@bradh352)
bradh352 added a commit that referenced this issue Dec 16, 2023
getrandom() can fail with ENOSYS if the libc supports the function but the kernel does not.

Fixes Bug: #660
Fix By: Brad House (@bradh352)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants