NetBSD Problem Report #56110

From gson@gson.org  Fri Apr 16 17:29:22 2021
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_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 24FDC1A924A
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 16 Apr 2021 17:29:22 +0000 (UTC)
Message-Id: <20210416172915.AACC4253F67@guava.gson.org>
Date: Fri, 16 Apr 2021 20:29:15 +0300 (EEST)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: pkg_add can fail without an error message
X-Send-Pr-Version: 3.95

>Number:         56110
>Category:       bin
>Synopsis:       pkg_add can fail without an error message
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 16 17:30:00 +0000 2021
>Last-Modified:  Sat Apr 17 12:35:01 +0000 2021
>Originator:     Andreas Gustafsson
>Release:        NetBSD-current, source date 2021.02.27.11.06.32
>Organization:
>Environment:
System: NetBSD
Architecture: aarch64
Machine: evbarm
>Description:

As I attempted to install a binary package on NetBSD/evbarm-aarch64
under qemu, pkg_add exited without printing an error message, giving
the impression that it had succeeded.

Yet it had clearly failed, because the exit status was nonzero (141,
suggesting an EPIPE?), and the package was left in a partially
installed state.

This PR is not about the package installation failing, as that may
have been caused by some network connectivity issue outside pkg_add's
control, but about pkg_add failing to print a message indicating that
it failed.

  arm64# pkg_add qemu
  pkg_add: Warning: package `qemu-5.2.0nb4' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `spice-server-0.14.3' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `glib2-2.66.8' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `pcre-8.44' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  Trying to reconnect https://cdn.NetBSD.org:443/pub/pkgsrc/packages/NetBSD/aarch64/9.0/All/glib2-2.66.8.tgz
  No schema files found: doing nothing.
  pkg_add: Warning: package `jpeg-9d' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `libiscsi-1.19.0' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `lzo-2.10' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `jemalloc-5.2.1nb2' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `perl-5.32.1' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `snappy-1.1.8' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `hicolor-icon-theme-0.17nb1' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `png-1.6.37' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `curl-7.76.0' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `libidn2-2.3.0' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `libunistring-0.9.10' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  pkg_add: Warning: package `nghttp2-1.43.0' was built for a platform:
  pkg_add: NetBSD/aarch64 9.0 (pkg) vs. NetBSD/aarch64 9.99.80 (this host)
  Trying to reconnect https://cdn.NetBSD.org:443/pub/pkgsrc/packages/NetBSD/aarch64/9.0/All/curl-7.76.0.tgz
  Trying to reconnect https://cdn.NetBSD.org:443/pub/pkgsrc/packages/NetBSD/aarch64/9.0/All/qemu-5.2.0nb4.tgz
  arm64# echo $?
  141
  arm64# pkg_delete qemu
  original MD5 checksum failed, not deleting: /usr/pkg/bin/qemu-ga
  pkg_delete: Couldn't remove /usr/pkg/bin/qemu-i386: No such file or directory
  pkg_delete: Couldn't remove /usr/pkg/bin/qemu-img: No such file or directory
  pkg_delete: Couldn't remove /usr/pkg/bin/qemu-io: No such file or directory
  [many more similar messages omitted]

>How-To-Repeat:

>Fix:

>Audit-Trail:
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/56110: pkg_add can fail without an error message
Date: Sat, 17 Apr 2021 05:18:11 +0700

     Date:        Fri, 16 Apr 2021 17:30:00 +0000 (UTC)
     From:        gson@gson.org (Andreas Gustafsson)
     Message-ID:  <20210416173000.CA24A1A924C@mollari.NetBSD.org>


   | Yet it had clearly failed, because the exit status was nonzero (141,
   | suggesting an EPIPE?)

 SIGPIPE - indicates that the process was killed by a signal (it had no chance
 to say anything).   Normally your shell would tell you about death by a signal,
 but shells tend not to make a noise about SIGPIPE exits, as they're so common.

   | This PR is not about the package installation failing, as that may
   | have been caused by some network connectivity issue outside pkg_add's
   | control, but about pkg_add failing to print a message indicating that
   | it failed.

 The only way to deal with that would be to have pkg_add catch SIGPIPE
 and write an error, or ignore it (SIG_IGN I mean, not do nothing), and
 deal with the EPIPE error it would get instead.

 If you're able to make this happen at will, try

 	trap '' PIPE

 before running the command, and see if that makes a difference.
 (This is not recommended as a general solution, just to confirm.)

 kre


From: Andreas Gustafsson <gson@gson.org>
To: Robert Elz <kre@munnari.OZ.AU>
Cc: gnats-bugs@netbsd.org
Subject: Re: bin/56110: pkg_add can fail without an error message
Date: Sat, 17 Apr 2021 15:32:38 +0300

 Robert Elz wrote:
 >    | Yet it had clearly failed, because the exit status was nonzero (141,
 >    | suggesting an EPIPE?)
 >  
 >  SIGPIPE - indicates that the process was killed by a signal (it had no chance
 >  to say anything).   Normally your shell would tell you about death by a signal,
 >  but shells tend not to make a noise about SIGPIPE exits, as they're so common.

 Right, SIGPIPE is what I meant :)

 >    | This PR is not about the package installation failing, as that may
 >    | have been caused by some network connectivity issue outside pkg_add's
 >    | control, but about pkg_add failing to print a message indicating that
 >    | it failed.
 >  
 >  The only way to deal with that would be to have pkg_add catch SIGPIPE
 >  and write an error, or ignore it (SIG_IGN I mean, not do nothing), and
 >  deal with the EPIPE error it would get instead.

 There's also F_SETNOSIGPIPE and MSG_NOSIGNAL.  If the SIGPIPE is
 happening inside a library such as libfetch or libssl, as I suspect is
 the case, I would argue that the right solution is to suppress or
 ignore it in the library unless it is a documented part of the library
 API.  There is already some code to do this in libfetch, but either
 it's not covering all the bases or the problem is somewhere else.

 > If you're able to make this happen at will,

 Alas, no.  Ideas for ways to do the necessary fault injection are welcome.
 -- 
 Andreas Gustafsson, gson@gson.org

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.