Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jun 1998 11:37:19 +0200 (CEST)
From:      Stefan Eggers <seggers@semyam.dinoco.de>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Cc:        seggers@semyam.dinoco.de
Subject:   bin/7020: pkg_*'s error handling is broken
Message-ID:  <199806220937.LAA20448@semyam.dinoco.de>

next in thread | raw e-mail | index | archive | help

>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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806220937.LAA20448>