From nobody@FreeBSD.org  Wed Aug  8 19:59:49 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A34F116A481
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  8 Aug 2007 19:59:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 8FF3713C4A3
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  8 Aug 2007 19:59:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l78JxnIc083981
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 8 Aug 2007 19:59:49 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l78Jxnik083980;
	Wed, 8 Aug 2007 19:59:49 GMT
	(envelope-from nobody)
Message-Id: <200708081959.l78Jxnik083980@www.freebsd.org>
Date: Wed, 8 Aug 2007 19:59:49 GMT
From: Michael Zhilin <mizhka@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] "pkg_delete -a" causes segmentation fault for package with broken dependency
X-Send-Pr-Version: www-3.0

>Number:         115327
>Category:       bin
>Synopsis:       [patch] "pkg_delete -a" causes segmentation fault for package with broken dependency
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    krion
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 08 20:00:12 GMT 2007
>Closed-Date:    Fri Jun 06 11:58:32 UTC 2008
>Last-Modified:  Fri Jun 06 11:58:32 UTC 2008
>Originator:     Michael Zhilin
>Release:        FreeBSD 7.0-CURRENT #1
>Organization:
>Environment:
FreeBSD reba 7.0-CURRENT FreeBSD 7.0-CURRENT #1: Wed Aug  1 06:13:10 MSD 2007     mizh@reba:/usr/obj/usr/src/sys/KRNL7  i386
>Description:
After year usage of FreeBSD as desktop the package system has contained a lot of broken dependencies, lost libraries (lib files without appropriate package) and other garbage. And of course, after updating to 7.0-current, some applications don't have been runnable (some errors with libthr have occured). It was reason for cleaning of system.

# pkg_deinstall -a
.. a lot of packages was deleted ...

# pkg_info 
.. 2 packages wasn't deleted ... 

pkg_deinstall was removed and a try to run "pkg_delete -a" causes following:
# pkg_delete -a
pkg_delete: Segmentation fault (core dumped)

After compilation with debug options gdb's given me a reason:
NULL pointer causes fault at /src/usr.sbin/pkg_install/delete/perform.c:line 266
>How-To-Repeat:
I think it was broken dependency
>Fix:
The attached patch works for me.

Patch attached with submission follows:

--- perform.c	2004-06-29 23:06:41.000000000 +0400
+++ perform.c.new	2007-08-08 22:33:33.000000000 +0400
@@ -266,7 +266,7 @@
     for (p = Plist.head; p ; p = p->next) {
 	if (p->type != PLIST_PKGDEP)
 	    continue;
-	deporigin = (p->next->type == PLIST_DEPORIGIN) ? p->next->name :
+	deporigin = ( p->next != NULL && p->next->type == PLIST_DEPORIGIN) ? p->next->name :
 							 NULL;
 	if (Verbose) {
 	    printf("Trying to remove dependency on package '%s'", p->name);


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->krion 
Responsible-Changed-By: remko 
Responsible-Changed-When: Wed Aug 8 20:53:12 UTC 2007 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=115327 
State-Changed-From-To: open->patched 
State-Changed-By: krion 
State-Changed-When: Sat Nov 10 22:57:27 UTC 2007 
State-Changed-Why:  
Fix committed to current, MFC after 3 days. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=115327 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/115327: commit references a PR
Date: Sat, 10 Nov 2007 22:57:19 +0000 (UTC)

 krion       2007-11-10 22:57:12 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.sbin/pkg_install/delete perform.c 
   Log:
   Fix segfault while running with -a option and deinstalling broken
   packages with incorrect plists.
   
   PR:             bin/115327
   Submitted by:   Michael Zhilin <mizhka@gmail.com>
   MFC after:      3 days
   
   Revision  Changes    Path
   1.42      +1 -1      src/usr.sbin/pkg_install/delete/perform.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: Volker <volker@vwsoft.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/115327: [patch] "pkg_delete -a" causes segmentation fault
 for package with broken dependency
Date: Sat, 08 Mar 2008 03:01:42 +0100

 Please note: MFC is missing
State-Changed-From-To: patched->closed 
State-Changed-By: gavin 
State-Changed-When: Fri Jun 6 11:57:41 UTC 2008 
State-Changed-Why:  
Close, patch was MFC'd to RELENG_7 and RELENG_6 by flz on 2008-04-07 
so will be fixed in 6.4 and 7.0-RELEASE 

http://www.freebsd.org/cgi/query-pr.cgi?pr=115327 
>Unformatted:
