From nobody@FreeBSD.org  Mon Mar  5 06:31:11 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 3EF8337B718
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  5 Mar 2001 06:31:11 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f25EVBS24379;
	Mon, 5 Mar 2001 06:31:11 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200103051431.f25EVBS24379@freefall.freebsd.org>
Date: Mon, 5 Mar 2001 06:31:11 -0800 (PST)
From: colle@krtkg1.rug.ac.be
To: freebsd-gnats-submit@FreeBSD.org
Subject: pkg_info dumps core
X-Send-Pr-Version: www-1.0

>Number:         25543
>Category:       bin
>Synopsis:       pkg_info dumps core
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 05 06:40:01 PST 2001
>Closed-Date:    Sun Mar 11 16:14:11 PST 2001
>Last-Modified:  Sun Mar 11 16:14:21 PST 2001
>Originator:     Christophe Colle
>Release:        FreeBSD 5.0-20010302-CURR
>Organization:
>Environment:
FreeBSD portie.pandora.be 5.0-20010302-CURRENT FreeBSD 5.0-20010302-CURRENT #0: Fri Mar  2 16:09:41 GMT 2001     root@usw2.freebsd.org:/usr/src/sys/compile/GENERIC  i386

>Description:
adding a package (with /stand/sysinstall or pkg_add) fails because
the subprocess pkg_info dumps core.

The stacktrace is:
bash-2.04# gdb /usr/sbin/pkg_info.bad  /var/tmp/instmp.9kfRWV/pkg_info.bad.core 
GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-freebsd"...
(no debugging symbols found)...
Core was generated by `pkg_info.bad'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libfetch.so.2...(no debugging symbols found)...
done.
Reading symbols from /usr/lib/libmd.so.2...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libc.so.5...(no debugging symbols found)...done.
Reading symbols from /usr/libexec/ld-elf.so.1...(no debugging symbols found)...
done.
#0  0x280f60fe in __vfprintf () from /usr/lib/libc.so.5
(gdb) $b
Undefined command: "".  Try "help".
(gdb) ba
#0  0x280f60fe in __vfprintf () from /usr/lib/libc.so.5
#1  0x280f04e7 in snprintf () from /usr/lib/libc.so.5
#2  0x8049a70 in free ()
#3  0x80499e6 in free ()
#4  0x8049699 in free ()

The command to generate the core is:
bash-2.04# ktrace -i pkg_add -v ~colle/mod_php4-4.0.4pl1.tgz 
Requested space: 1480852 bytes, free space: 17775616 bytes in /var/tmp/instmp.9kfRWV
Package `mod_php4-4.0.4pl1' depends on `mysql-client-3.23.33'.
Segmentation fault - core dumped
pkg_add: could not find package mysql-client-3.23.33 !
Package `mod_php4-4.0.4pl1' depends on `apache-1.3.17_1'.
Segmentation fault - core dumped
pkg_add: could not find package apache-1.3.17_1 !


>How-To-Repeat:
pkg_add mod_php4-4.0.4pl1.tgz
>Fix:
temp fix:
replace pkg_info with pkg_info from FBSD4.
and fbsd 5 flies again
>Release-Note:
>Audit-Trail:

From: Christophe Colle <colle@krtkg1.rug.ac.be>
To: freebsd-gnats-submit@FreeBSD.org, colle@krtkg1.rug.ac.be
Cc:  
Subject: Re: bin/25543: pkg_info dumps core
Date: Mon, 5 Mar 2001 16:05:09 +0100 (MET)

 The core dump is due to accessing uninitialized memory:
 
 pkg_perform(char **pkgs)
 {
     char **matched;
     char *tmp;
     int err_cnt = 0;
     int i, errcode;
 
     signal(SIGINT, cleanup);
 
     /* Overriding action? */
     if (CheckPkg) {
         char buf[FILENAME_MAX];
 
         snprintf(buf, FILENAME_MAX, "%s/%s", tmp, CheckPkg);
         return abs(access(buf, R_OK));
         /* Not reached */
     }
 
 
 
 
 the variable tmp is never initialised:
 add the follwoing line:
         tmp = getenv(PKG_DBDIR)?getenv(PKG_DBDIR):DEF_LOG_DIR;
 
 so the code looks like:
 
 pkg_perform(char **pkgs)
 {
     char **matched;
     char *tmp;
     int err_cnt = 0;
     int i, errcode;
 
     signal(SIGINT, cleanup);
 
     /* Overriding action? */
     if (CheckPkg) {
         char buf[FILENAME_MAX];
         tmp = getenv(PKG_DBDIR)?getenv(PKG_DBDIR):DEF_LOG_DIR;
 
         snprintf(buf, FILENAME_MAX, "%s/%s", tmp, CheckPkg);
         return abs(access(buf, R_OK));
         /* Not reached */
     }
 
 
 
 Now it flies again....
 
 
 Christophe Colle
 
      | \       =============================================================  
      |  \      Colle Christophe                    Phone: +32-(0)3-886.39.83
      |   \     mail: colle@krtkg1.rug.ac.be   http://krtkg1.rug.ac.be/~colle
      +-----          
      |
  ----------+   When I'm in Ghent, then I'm probably at Anouk's place..
   \________|   =======     Radiotherapy Department, Ghent      =============
 
 
 
 

From: Garrett Rooney <rooneg@electricjellyfish.net>
To: freebsd-gnats-submit@freebsd.org, colle@krtg1.rug.ac.be,
	sobomax@freebsd.org
Cc:  
Subject: Re: bin/25543: pkg_info dumps core
Date: Sun, 11 Mar 2001 14:57:38 -0500

 This has been fixed.  Revision 1.36 of perform.c puts these lines back in, so
 this pr should be closed.
 
 -- 
 garrett rooney                        Unix was not designed to stop you from 
 rooneg@electricjellyfish.net          doing stupid things, because that would  
 http://electricjellyfish.net/         stop you from doing clever things.
State-Changed-From-To: open->closed 
State-Changed-By: kris 
State-Changed-When: Sun Mar 11 16:14:11 PST 2001 
State-Changed-Why:  
Problem resolved 


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