From owner-freebsd-bugs Mon Jun 22 07:32:09 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA08652 for freebsd-bugs-outgoing; Mon, 22 Jun 1998 07:32:09 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA08588 for ; Mon, 22 Jun 1998 07:31:43 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id HAA27104; Mon, 22 Jun 1998 07:30:01 -0700 (PDT) Received: from tim.xenologics.com (tim.xenologics.com [194.77.5.24]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA06754 for ; Mon, 22 Jun 1998 07:23:09 -0700 (PDT) (envelope-from seggers@semyam.dinoco.de) Received: (from uucp@localhost) by tim.xenologics.com (8.8.5/8.8.8) with UUCP id QAA07167 for FreeBSD-gnats-submit@freebsd.org; Mon, 22 Jun 1998 16:18:40 +0200 (MET DST) Received: (from seggers@localhost) by semyam.dinoco.de (8.8.8/8.8.8) id LAA20448; Mon, 22 Jun 1998 11:37:19 +0200 (CEST) (envelope-from seggers) Message-Id: <199806220937.LAA20448@semyam.dinoco.de> Date: Mon, 22 Jun 1998 11:37:19 +0200 (CEST) From: Stefan Eggers Reply-To: seggers@semyam.dinoco.de To: FreeBSD-gnats-submit@FreeBSD.ORG Cc: seggers@semyam.dinoco.de X-Send-Pr-Version: 3.2 Subject: bin/7020: pkg_*'s error handling is broken Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 7020 >Category: bin >Synopsis: pkg_*'s error handling is broken >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jun 22 07:30:00 PDT 1998 >Last-Modified: >Originator: Stefan Eggers >Organization: none >Release: FreeBSD 2.2.6-STABLE i386 >Environment: My little 2.2-stable system. CVSUp'ed last weekend. >Description: While improving pkg_create I discovered that the error handling of pkg_create (and the other pkg_*, too) is seriously broken. It will never print an error message about certain errors to the user thus making him/her wonder why it failed. The problem is the statement "cleanup(0), errx(1, "ABC");" - cleanup() does an exit(1) at its end in all cases. The errx() will never get executed. And as the errx() is the only place printing an error message ... I also saw the variable in_cleanup in it which is automatic and gets initialized to 0. The next thing done there is testing if this variable is not set. Probably this variable should have been static but I'll have to take a closer look at it to be sure. The former problem at least exists in pkg_add, too. I did not look at the other pkg_*, yet. The latter problem does not exist there - the variable is static. >How-To-Repeat: Just take a look at the code. >Fix: Not sure about how to best fix it. If all cleanup() calls get followed by errx() it will be safe to just remove the exit(). This will break its use as signal handler. A signalcleanup() should be added which calls the old cleanup() and then does the exit() I think. The variable in cleanup() serve as a flag so that it doesn't get called from the program and at the same time by the signal processing. Making it static should fix this problem and make it actually work as intended. >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message