curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Infinite loop in wakeup check in Curl_multi_wait

From: Dunaj, Robert via curl-users <curl-users_at_cool.haxx.se>
Date: Wed, 26 Feb 2020 13:51:05 +0000

Hi

Our application started to have higher cpu after libcurl upgrade from 7.66.0 to 7.68.0
It turned out that the affected thread was in infinite loop in https://github.com/curl/curl/blame/master/lib/multi.c#L1202 - sread is called repeatedly there in line 1202:

#ifdef ENABLE_WAKEUP
      if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
        if(ufds[curlfds + extra_nfds].revents & POLLIN) {
          char buf[64];
          while(1) {
            /* the reading socket is non-blocking, try to read
               data from it until it receives an error (except EINTR).
               In normal cases it will get EAGAIN or EWOULDBLOCK
               when there is no more data, breaking the loop. */
Line 1202: if(sread(multi->wakeup_pair[0], buf, sizeof(buf)) < 0) {
#ifndef USE_WINSOCK
              if(EINTR == SOCKERRNO)
                continue;
#endif
              break;
            }
          }
          /* do not count the wakeup socket into the returned value */
          retcode--;
        }
      }
#endif

It happens on Amazon Linux AMI 2018.03 (kernel 4.14.114-83.126.amzn1.x86_64) machine.
I attached with the gdb and buf content is not changing after each read.
So I suspect that sread returns 0 (end of file).
Shouldn't == 0 check be added there?

Kind regards
"The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. Dynatrace sp. z o.o. (registration number KRS 595) is a company registered in Poland whose registered office is at ul. Grunwaldzka 411,80-309 Gdansk Rejestr handlowy KRS 0000000595 Sadu Rejonowego Gdansk-Polnoc w Gdansku VII Wydzial Gospodarczy Kapital zakladowy 4.240.000 zl oplacony gotówka; NIP: 584-20-88-050; REGON: 191352920"

-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-02-26