NetBSD Problem Report #55845

From he@smistad.uninett.no  Sat Dec  5 12:37:23 2020
Return-Path: <he@smistad.uninett.no>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7212E1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  5 Dec 2020 12:37:23 +0000 (UTC)
Message-Id: <20201205123717.204C943FB38@smistad.uninett.no>
Date: Sat,  5 Dec 2020 13:37:17 +0100 (CET)
From: he@NetBSD.org
Reply-To: he@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: pkgin may cause pkg_add to dump core
X-Send-Pr-Version: 3.95

>Number:         55845
>Category:       pkg
>Synopsis:       pkgin may cause pkg_add to dump core
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 05 12:40:00 +0000 2020
>Last-Modified:  Sun Dec 06 12:25:01 +0000 2020
>Originator:     he@NetBSD.org
>Release:        NetBSD 9.0_STABLE
>Organization:
	I try...
>Environment:


System: NetBSD smistad.uninett.no 9.0_STABLE NetBSD 9.0_STABLE (GENERIC) #0: Sat May 30 02:09:41 CEST 2020 he@smistad.uninett.no:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

	I had postgres95-client installed, but in a pkg upgrade to
	2020Q3 packages, pkgin wanted to install postgresql12-client
	instead.  This was installed as a dependency of
	p5-DBD-postgresql, so when trying to reinstall that without
	tidying up the old posgresql95-client package, I experienced
	this:

# pkgin in p5-DBD-postgresql
calculating dependencies...done.
postgresql12-client-12.4nb1 (to be installed) conflicts with installed package postgresql95-client-9.5.23nb1.
proceed ? [y/N] n
Segmentation fault (core dumped)
# pkg_info | grep pkgin
pkgin-20.8.0        Apt / yum like tool for managing pkgsrc binary packages
#
# ls -l *.core
-rw-------  1 root  wsrc  4885936 Dec  4 14:33 pkg_add.core
# 

	What?!?  Why would pkgin run pkg_add behind my back when I
	said that pkgin should *not* proceed?

	I *think* pkgin uses /usr/pkg/sbin/pkg_add (not sure), if so
	this points to a string comparison against ... null? 

# gdb /usr/pkg/sbin/pkg_add pkg_add.core
...
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000074a4d756b490 in strcmp () from /usr/lib/libc.so.12
(gdb) where
#0  0x000074a4d756b490 in strcmp () from /usr/lib/libc.so.12
#1  0x0000000000440147 in check_dependencies ()
#2  0x0000000000407a33 in pkg_do ()
#3  0x000000000040805f in pkg_perform ()
#4  0x0000000000440440 in main ()
(gdb)

(gdb) i reg
...
rdi            0xfffffffffffffff8  -8
...
rip            0x74a4d756b490      0x74a4d756b490 <strcmp+64>
...
(gdb) x/i 0x74a4d756b490
=> 0x74a4d756b490 <strcmp+64>:  mov    0x8(%rdi),%rax
(gdb) 


>How-To-Repeat:
	Have an old p5-DBD-postgresql installed, together with an old
	postgres95-client package.

>Fix:
	Sorry, no suggestion here.

>Audit-Trail:
From: Jonathan Perkin <jperkin@joyent.com>
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/55845: pkgin may cause pkg_add to dump core
Date: Sat, 5 Dec 2020 13:47:43 +0000

 * On 2020-12-05 at 12:40 GMT, he@NetBSD.org wrote:

 > # pkgin in p5-DBD-postgresql
 > calculating dependencies...done.
 > postgresql12-client-12.4nb1 (to be installed) conflicts with installed package postgresql95-client-9.5.23nb1.
 > proceed ? [y/N] n
 > Segmentation fault (core dumped)
 > # pkg_info | grep pkgin
 > pkgin-20.8.0        Apt / yum like tool for managing pkgsrc binary packages

 This is a known bug in 20.8.0, fixed in 20.11.0

 > # ls -l *.core
 > -rw-------  1 root  wsrc  4885936 Dec  4 14:33 pkg_add.core

 Are you sure this is the core that was dumped above?  I would expect
 to see a pkgin core.

 > 	What?!?  Why would pkgin run pkg_add behind my back when I
 > 	said that pkgin should *not* proceed?

 I'm almost certain it wouldn't, certainly the only place it does run
 (actions.c, do_pkg_install()), you would expect to see some further
 output beforehand, which doesn't match your output.

 If this really is a pkg_add.core from a pkgin segfault, then I think
 the only thing that would explain this is a really bad build that is
 completely re-arranging some of the code.

 -- 
 Jonathan Perkin  -  Joyent, Inc.  -  www.joyent.com

From: Havard Eidnes <he@NetBSD.org>
To: gnats-bugs@netbsd.org, jperkin@joyent.com
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/55845: pkgin may cause pkg_add to dump core
Date: Sun, 06 Dec 2020 13:21:00 +0100 (CET)

 >  > # pkgin in p5-DBD-postgresql
 >  > calculating dependencies...done.
 >  > postgresql12-client-12.4nb1 (to be installed) conflicts with insta=
 lled package postgresql95-client-9.5.23nb1.
 >  > proceed ? [y/N] n
 >  > Segmentation fault (core dumped)
 >  > # pkg_info | grep pkgin
 >  > pkgin-20.8.0        Apt / yum like tool for managing pkgsrc binary=
  packages
 >
 >  This is a known bug in 20.8.0, fixed in 20.11.0

 Ah, that's encouraging.  I'll upgrade and this bug report can be
 closed.

 Following up on the other points:

 >  > # ls -l *.core
 >  > -rw-------  1 root  wsrc  4885936 Dec  4 14:33 pkg_add.core
 >
 >  Are you sure this is the core that was dumped above?  I would expect=

 >  to see a pkgin core.

 I've searched, and I can't find the pkgin.core file.
 Besides, the timestamp on the pkg_add.core file matches the above
 action.

 >  > 	What?!?  Why would pkgin run pkg_add behind my back when I
 >  > 	said that pkgin should *not* proceed?
 >
 >  I'm almost certain it wouldn't, certainly the only place it does run=

 >  (actions.c, do_pkg_install()), you would expect to see some further
 >  output beforehand, which doesn't match your output.
 >
 >  If this really is a pkg_add.core from a pkgin segfault, then I think=

 >  the only thing that would explain this is a really bad build that is=

 >  completely re-arranging some of the code.

 Strange.  I see the above comes from

                 /* check for conflicts */
                 if (pkg_has_conflicts(pkg))
                         if (!check_yesno(DEFAULT_NO))
                                 goto installend;

 but from the installend label it will return from the
 pkg_install() function, and rc may be defaulted to EXIT_SUCCESS
 still.

 Well.  I've browsed some more at the code, and can't find a
 smoking gun, and it's possible I wasn't fully alert until the
 above happened.  I'm satisfied with upgrading pkgin and let it be
 with that.

 Regards,

 - H=E5vard

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.