#60581 closed defect (fixed)
garbage error output from failed curl
Reported by: | ryandesign (Ryan Carsten Schmidt) | Owned by: | neverpanic (Clemens Lang) |
---|---|---|---|
Priority: | Normal | Milestone: | MacPorts 2.6.3 |
Component: | base | Version: | 2.6.2 |
Keywords: | Cc: | neverpanic (Clemens Lang) | |
Port: |
Description
I'm trying to fix an old port by fetching its distfiles from archive.org. archive.org is having some problem today where I have to refresh its pages several times before it shows me the information I want; other times I get various connection errors. In addition, connections to "distfiles.macports.org" will not succeed because on my network that is mapped to a custom server that is offline right now.
Trying to fetch the modified port with MacPorts (on High Sierra) I got this output:
---> Attempting to fetch p4d from https://web.archive.org/web/20101114082044if_/http://filehost.perforce.com/perforce/r10.1/bin.darwin80u/ % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 125k 0 125k 0 0 112k 0 --:--:-- 0:00:01 --:--:-- 112k DEBUG: Fetching distfile failed: transfer closed with outstanding read data remaining ---> Attempting to fetch p4d from https://distfiles.macports.org/perforce/2010.1 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0DEBUG: Fetching distfile failed: ½Å Error: Failed to fetch perforce: ½Å DEBUG: Error code: NONE DEBUG: Backtrace: ½Å while executing "error $lastError" (procedure "portfetch::fetchfiles" line 66) invoked from within "portfetch::fetchfiles" (procedure "portfetch::fetch_main" line 17) invoked from within "$procedure $targetname" Error: See /opt/local/var/macports/logs/_Users_rschmidt_macports_macports-ports-svn-trunk-new_devel_perforce/perforce/main.log for details. Error: Follow https://guide.macports.org/#project.tickets to report a bug. Error: Processing of port perforce failed
Regardless of how badly the servers from which I'm downloading are behaving, I should never see an "error message" like ½Å
.
Change History (6)
comment:1 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)
Cc: | neverpanic added |
---|
comment:2 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)
The example code in the documentation shows that the buffer should be initialized to the empty string using:
char errbuf[CURL_ERROR_SIZE];
/* set the error buffer as empty before performing a request */ errbuf[0] = 0;
comment:3 Changed 4 years ago by neverpanic (Clemens Lang)
comment:4 Changed 4 years ago by neverpanic (Clemens Lang)
Owner: | set to neverpanic |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:5 Changed 4 years ago by neverpanic (Clemens Lang)
Milestone: | → MacPorts 2.6.3 |
---|
Cherry-pick to release-2.6 in [cd583fee1071e93367abc89f8bd4e7128621404a/macports-base].
comment:6 Changed 4 years ago by neverpanic (Clemens Lang)
Just seen this in build output generated by Travis, and the change seems to work as expected. See https://paste.macports.org/75dc136dfd83:
Error: Failed to fetch py38-lxml: curl_multi_info_read() returned {.msg = CURLMSG_DONE, .data.result = 7 (!= CURLE_OK)}, but the error buffer is not set. curl_easy_strerror(.data.result): Couldn't connect to server
Looking through the code in CurlFetchCmd in src/pextlib1.0/curl.c, I see this:
This tells curl to fill theErrorString with an error message if it occurs.
We later use that variable like this:
I think the problem is that curl does not guarantee that it has filled the error buffer with anything, even if an error occurred. From the documentation:
I was using High Sierra, whose libcurl version if 7.54.0, which means it does not initialize the error buffer to the empty string. It would probably be a good idea for us to initialize it to the empty string. And later when we want to pass it to Tcl, we might want to check if it is still the empty string and if so substitute a generic error message.