From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Aug 29 06:50:08 2012 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C4D7106564A for ; Wed, 29 Aug 2012 06:50:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 024928FC15 for ; Wed, 29 Aug 2012 06:50:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q7T6o6A9013675 for ; Wed, 29 Aug 2012 06:50:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q7T6o6vS013674; Wed, 29 Aug 2012 06:50:06 GMT (envelope-from gnats) Resent-Date: Wed, 29 Aug 2012 06:50:06 GMT Resent-Message-Id: <201208290650.q7T6o6vS013674@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Stefan Esser Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 59DC4106575B for ; Wed, 29 Aug 2012 06:42:47 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 73E5F8FC0A for ; Wed, 29 Aug 2012 06:42:47 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q7T6glfX084934 for ; Wed, 29 Aug 2012 06:42:47 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q7T6glQc084931; Wed, 29 Aug 2012 06:42:47 GMT (envelope-from nobody) Message-Id: <201208290642.q7T6glQc084931@red.freebsd.org> Date: Wed, 29 Aug 2012 06:42:47 GMT From: Stefan Esser To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/171155: PKGNG fails to deinstall large ports X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Aug 2012 06:50:08 -0000 >Number: 171155 >Category: ports >Synopsis: PKGNG fails to deinstall large ports >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Aug 29 06:50:06 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Stefan Esser >Release: 10-CURRENT >Organization: FreeBSD >Environment: FreeBSD xyzzy 10.0-CURRENT FreeBSD 10.0-CURRENT #33 r239375M: Sun Aug 19 00:18:08 CEST 2012 root@xyzzy:/sys/amd64/compile/SE amd64 >Description: PKG_NG seems to have introduced a limit on the size of ports that can be deinstalled: I have located the line that is causing this error. It is the posix_spawn on line 102 of libpkg/script.c. The argument length is limited to KERN_ARGMAX (sysctl kern.argmax) which seems to be a R/O value initialized to 256KB. AFAICT this is not even a loader tuneable. A new kernel must be built, or pkg must be modified to honor the argument length limit. The argument is the string argument of "sh -c ", which can not be split in the general case. In the specific case of math/lapack, the arguments to execve() (called by posix_spawn()) are: argv[0] = "sh" argv[1] = "-c" argv[2] = " set -- lapack-3.4.0_2 rm -f /usr/local/man/cat3/INSTALL_ilaver.f.3.gz ... /usr/local/man/cat3/zupmtr.f.3.gz.bz2" (==> ~330KB total!) The argument list must be broken into pieces of less than 256KB, since rising KERN_ARGMAX to >330KB will lead to the same problem with the next port with even longer PLIST. >How-To-Repeat: On a system with pkg-1.0.r6_1 installed and WITH_PKGNG=yes in /etc/make.conf: # cd /usr/ports/math/lapack # make all install (... or "pkg install lapack" ...) # make deinstall (... or "pkg delete lapack" ...) ===> Deinstalling for math/lapack ===> Deinstalling lapack-3.4.0_2 The following packages will be deinstalled: lapack-3.4.0_2 The deinstallation will free 28 MB Deinstalling lapack-3.4.0_2...lapack-3.4.0_2 is required by: qrupdate-1.1.1, deleting anyway pkg: Cannot run script(DEINSTALL): Argument list too long *** [deinstall] Error code 3 # >Fix: The problem is that execve() returns E2BIG for arguments that exceed KERN_ARGMAX and this is a parameter that is compiled into the kernel. Rising the limit is no fix, since another port could easily exceed any new limit. The best solution seems to be: - instantiate the shell with popen instead of posix_spawn() - do not use "-c" to pass the shell commands as arguments - pipe the shell commands into the shell (this assumes, that the shell does not implement a similar limit on the length of a comamnd, but I have not verified that assumption) If the shell implements a length limit on its commands: - identify shell commands that may be split over multiple lines - repeatedly call the command with a parameter list shorter than allowed by KERN_ARGMAX >Release-Note: >Audit-Trail: >Unformatted: