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

multi_wait() ignores Curl_poll() errors #8921

Closed
piru opened this issue May 26, 2022 · 3 comments
Closed

multi_wait() ignores Curl_poll() errors #8921

piru opened this issue May 26, 2022 · 3 comments

Comments

@piru
Copy link

@piru piru commented May 26, 2022

multi_wait() ignores the potential error from Curl_poll() at

curl/lib/multi.c

Line 1315 in d67f41a

If Curl_poll() returns immediately the function will then return CURLM_OK right away without performing any waiting. This will lead curl_multi_poll()/curl_multi_wait() to return immediately as well. Effectively this will lead to a busyloop as there is no status returned that would lead to terminating a loop of a typical curl_multi_perform() + curl_multi_poll() app, at least if the app doesn't bail out once the connections are completed (still_running == 0 doesn't lead to loop termination).

I did this

Had condition where poll() (or select() if using poll() emulation) return a permanent error without waiting.

I expected the following

curl_multi_poll() / curl_multi_wait() to return an error if Curl_poll() fails.

The question is what error to return though as none of the CURLM_ errors seem to fit the bill.

curl/libcurl version

7.83.1

operating system

This is a generic issue, but it is likely more likely to get triggered on specific platforms.

@bagder
Copy link
Member

@bagder bagder commented May 27, 2022

I don't think all poll/select errors are permanent though, are they? Should all underlying errors make curl_multi_poll()/wait() return error?

@piru
Copy link
Author

@piru piru commented May 27, 2022

ERRORS
       EFAULT fds  points  outside the process's accessible address space.  The array given as
              argument was not contained in the calling program's address space.

       EINTR  A signal occurred before any requested event; see signal(7).

       EINVAL The nfds value exceeds the RLIMIT_NOFILE value.

       EINVAL (ppoll()) The timeout value expressed in *ip is invalid (negative).

       ENOMEM Unable to allocate memory for kernel data structures.

Indeed, EINTR probably should not be considered fatal.

@piru
Copy link
Author

@piru piru commented May 27, 2022

lib/easy.c wait_or_timeout() seems to have the same issue btw

curl/lib/easy.c

Line 509 in a77d14d

pollrc = Curl_poll(fds, numfds, ev->ms);

lib/asyn-ares.c waitperform() as well. waitperform() result is not checked, which seems to be wrong as well.

nfds = Curl_poll(pfd, num, timeout_ms);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants