curl / Mailing Lists / curl-library / 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.

Re: libcurl hangs in curl_multi_cleanup

From: FirefoxOS via curl-library <curl-library_at_cool.haxx.se>
Date: Tue, 22 Jun 2021 17:33:51 +0200

Dnia 2021-06-18, o godz. 23:53:57
Daniel Stenberg <daniel_at_haxx.se> napisaƂ(a):

> On Fri, 18 Jun 2021, Firefox OS via curl-library wrote:
>
> > Do you mean imap://...? Yes, it does. And the callstack looks the
> > same.
>
> I cannot reproduce. I converted "curl_imap_teardown_issue.c" into
> test case 677 in this commit:
> https://github.com/curl/curl/commit/4401aede3133d1db9e3cc907b3c6640eda06c57a
>
> You can check out this branch:
> https://github.com/curl/curl/tree/bagder/multi_cleanup-imap-test
>
> And if you build the code and the tests run 677 like:
>
> cd tests && make -sj7 && ./runtests.pl 677
>
> Can you figure out what we need to change to make lib677.c hang?
>

Thanks for creating a test case.

The problem cannot be directly reproduced using curl test suite because
ftpserver.pl doesn't support IMAP IDLE mode (RFC2177). Please have a
look at repro1.patch which adds very limited support of idle mode to
ftpserver.pl (so that idle mode can be entered but not exited). The
result is now the same as I observe using a real IMAP server:

---cut here---
test 0677...[IMAP with CONNECT_ONLY, custom command then exit]
--p----e-v- OK (1 out of 1 , remaining: 00:00, took 126.621s, duration: 02:06)
TESTDONE: 1 tests were considered during 127 seconds.
TESTDONE: 1 tests out of 1 reported OK: 100%
---cut here---

(Please also note that I replaced A1 IDLE\n with A1 IDLE\r\n because
ftpserver.pl doesn't seem to accept commands terminated with just \n,
contrary to the server I used before.)

What I wasn't aware of before I saw your test677 file is that
after libcurl "finishes" CONNECT_ONLY connection and passes
ACTIVE_SOCKET to the application, it still wants to proceed with A002
LOGOUT command (waiting for a "correct" answer) despite it has no idea
what the state of the connection can be and what the server will do
after receiving such string. Since the responsibility for the
conversation has been already transferred to the application, I expect
libcurl to avoid sending anything. I expressed this in repro2.patch
(forget about repro1.patch) and now, without touching ftpserver.pl, the
result is as follows:

---cut here---
test 0677...[IMAP with CONNECT_ONLY, custom command then exit]

 677: protocol FAILED:
--- log/check-expected 2021-06-22 17:30:42.767593317 +0200
+++ log/check-generated 2021-06-22 17:30:42.767593317 +0200
_at__at_ -1,2 +1,3 _at__at_
 A001 CAPABILITY[CR][LF]
 A1 IDLE[CR][LF]
+A002 LOGOUT[CR][LF]

 - abort tests
TESTDONE: 1 tests were considered during 7 seconds.
TESTDONE: 0 tests out of 1 reported OK: 0%

TESTFAIL: These test cases failed: 677
---cut here---


-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Received on 2021-06-22