When you pkg_add something from a URL when the dependencies aren't all installed, pkg_add will attempt to auto-install the dependent packages for you. but it doesn't work. Fix: ------------------------------------------------------------ for src/lib/libftpio/ ------------------------------------------------------------ for src/usr.sbin/pkg_install/lib might also want to add the '.tar.gz' case too? How-To-Repeat: without having autoconf or m4 installed, i did # pkg_add -v "ftp://ftp/u9/freebsd/packages-2.1.5/All/autoconf-2.10.tgz" Trying to fetch ftp://ftp/u9/freebsd/packages-2.1.5/All/autoconf-2.10.tgz. Extracting from FTP connection into /var/tmp/instmp.014625 +CONTENTS [... and so on ...] share/autoconf/config.sub tar command returns 0 status Package `autoconf-2.10' depends on `m4-1.4'. Trying to fetch ftp://ftp/u9/freebsd/packages-2.1.5/All/m4-1.4. Error: FTP Unable to get ftp://ftp/u9/freebsd/packages-2.1.5/All/m4-1.4 Segmentation fault (core dumped) So, i looked into why the .tgz extension isn't being added in, and added that (see patches to pkg_install/lib/file.c below) then retried after a similar output it died on a 'Broken Pipe' signal after trying to fetch the right file. (i can't cut and paste because vi trashed the scrollback buffer) anyway, i traced this to a thing inside libftpio where with ftpGetURL, an static FILE* is being closed on each re-open. I suspect that the fclose done in ftpGetURL() is to avoid exhausting file descriptors... anyway what i have now works, even though some FILE*'s are left unclosed. i could not see straight away where the sigpipe was coming from... should have kept the core :(
> So, i looked into why the .tgz extension isn't being added in, and > added that (see patches to pkg_install/lib/file.c below) then > retried Genuine bug, thanks. > anyway, i traced this to a thing inside libftpio where with > ftpGetURL, an static FILE* is being closed on each re-open. > > I suspect that the fclose done in ftpGetURL() is to avoid > exhausting file descriptors... anyway what i have now works, Erm, sort of. :-( That construct is very deliberately the way it is, due to the fact that when you open a connection to an FTP, that returns one FILE*. If you then ask for a file from that connection, it returns another FILE*. Now, and this is the important part, if you close the first file pointer before finishing with the second, you lose. The intended use of ftpGetURL() was that you'd process the file it returned all the way to completion and close it before asking for another URL. This is clearly not what pkg_add is doing, and pkg_add has a bug I'll have to look into. Leaving leaks in libftpio is not an acceptable solution by any conceivable stretch. However, you have suggested an important optimization to me, and that's to cache the old host connection when getting ftpGetURL() requests back-to-back for the same host. That just makes simple sense, and was easy to do. I'll commit the changes shortly to libftpio, as well as some fixes to pkg_add. Jordan
Responsible Changed From-To: freebsd-bugs->jkh pkg_* is Jordans area.
State Changed From-To: open->closed There were indeed entomological artifacts in this code - thanks for the bug report. Fixed!