Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE segfault when "verbose" is enabled #96

Merged
merged 1 commit into from
Aug 20, 2020

Conversation

dhgutteridge
Copy link
Contributor

Prior to revision b606826, log_tag() was only ever invoked when err_fp
was guaranteed to be assigned. After that revision, it could be called
with err_fp being null. Carry some of the old "!verbose" logic into
log_tag() to address this.

Prior to revision b606826, log_tag() was only ever invoked when err_fp
was guaranteed to be assigned. After that revision, it could be called
with err_fp being null. Carry some of the old "!verbose" logic into
log_tag() to address this.
@dhgutteridge
Copy link
Contributor Author

dhgutteridge commented Aug 18, 2020

This may be unrelated to #94. I haven't tested that one. The stack
trace in #94 looks rather different. My reproduction details and
(though probably unnecessary here, except to compare with #94)
backtrace follow.

Running "pkgin -V upgrade mate" (on a local repo, not that that
matters) resulted in a segfault on NetBSD -current (9.99.71/amd64).

$ pkgin -V upgrade mate
reading local summary...
processing local summary...
calculating dependencies...done.

156 packages to refresh:
xorg-util-macros-1.19.2 xmlcatmgr-2.2nb1 wayland-1.18.0nb1 swig-1.3.38nb1 shared-mime-info-1.10nb2 rust-bin-1.44.0 re2c-1.1.1
py27-gobject-2.28.7nb2 py27-expat-2.7.18 py-gobject3-common-3.36.1 py-gobject-shared-2.28.7nb4 ptexenc-1.3.8
poppler-includes-0.87.0 perl-5.30.3 pcre-8.44 patchelf-0.10 p5-XML-SAX-Expat-0.51nb5 p5-XML-SAX-Base-1.09nb3 p5-XML-SAX-1.00nb2
p5-XML-NamespaceSupport-1.12nb3 p11-kit-0.23.15nb1 nss-3.55 nettle-3.6 mozjs60-60.8.0nb6 mktexlsr-2020 lzo-2.10 lzip-1.21
lua53-5.3.5 libxslt-1.1.34nb2 libxklavier-5.4nb5 libwnck3-3.24.1nb8 libuuid-2.32.1 libunistring-0.9.10 libunique-1.1.6nb31
libtool-base-2.4.6nb2 libtasn1-4.16.0 librsvg-2.48.3nb1 libpaper-1.1.28 libogg-1.3.4nb1 libindicator-12.10.1nb11
libimagequant-2.12.6 libgnome-keyring-3.12.0nb1 libglade-2.6.4nb34 libfakekey-0.1 libcfg+-0.7.0 libcanberra-0.30nb3 libXft-2.3.3
kpathsea-6.3.2 iso-codes-3.77nb1 intltool-0.51.0nb4 icon-naming-utils-0.8.90nb7 gtksourceview3-3.24.11nb3
gtk2-engines-murrine-0.98.2nb11 gtk2-engines-2.20.2nb28 gtk2+-2.24.32nb14 gstreamer1-1.16.2nb1 gsettings-desktop-schemas-3.24.0nb1
gsed-4.8 gperf-3.1 gnome-doc-utils-0.20.10nb5 gmake-4.2.1nb1 ghostscript-fonts-8.11nb3 getopt-1.1.6 fontconfig-2.13.1
docbook-xml-4.5 digest-20190127 cwrappers-20180325 compat80-8.0 checkperms-1.12 autoconf213-2.13nb8 autoconf-archive-2019.01.06
autoconf-2.69nb9 x11-links-1.31 zziplib-0.13.69 graphviz-2.44.1 gd-2.3.0 atril-1.24.0nb1 gdk-pixbuf2-2.40.0nb1 xcb-util-0.4.0
gucharmap-2.32.1nb30 pluma-1.24.0nb1 desktop-file-utils-0.26 mate-terminal-1.24.0nb1 mate-utils-1.24.0 mate-themes-3.22.21
mate-session-manager-1.24.0 mate-polkit-1.24.0 mate-notification-daemon-1.24.0 mate-netbook-1.24.0 mate-indicator-applet-1.24.0
mate-icon-theme-faenza-1.20.0nb6 mate-icon-theme-1.24.0 mozo-1.24.0 gtk-doc-1.32nb3 engrampa-1.24.0 caja-dropbox-1.24.0
libnotify-0.7.9nb2 itstool-2.0.6nb1 gobject-introspection-1.64.1 libxkbcommon-0.10.0 pango-1.44.7nb2 py37-cairo-1.18.2
py27-cairo-1.18.2 python27-2.7.18 poppler-0.87.0 cairo-1.16.0nb1 mate-desktop-1.24.0 libpeas-1.26.0 gts-0.7.6nb1 gawk-5.0.1
mate-menus-1.24.0 libgtop-2.28.4nb17 vte3-0.60.3nb1 polkit-0.116nb3 libmatekbd-1.24.0nb1 upower-0.99.11 pam-pwauth_suid-1.2nb1
mate-settings-daemon-1.24.0nb1 marco-1.24.1 gnome-keyring-2.32.1nb29 p5-XML-Parser-2.44nb5 p5-XML-Simple-2.25nb2 enchant2-2.2.8nb1
p5-gettext-1.07nb4 GConf-3.2.3nb5 py37-pygments-2.5.2 py37-anytree-2.8.0 pkgconf-1.6.0 py27-libxslt-1.1.34nb1
py27-libxml2-2.9.10nb1 ORBit2-2.14.19nb5 dbus-glib-0.110nb1 cairo-gobject-1.16.0nb4 readline-8.0 json-glib-1.4.4nb1
consolekit-1.2.1nb4 nghttp2-1.41.0 libidn2-2.3.0 libuv-1.38.1 curl-7.71.1 py37-docutils-0.16 m4-1.4.18nb2 web2c-2020nb1
poppler-glib-0.87.0 libgxps-0.2.2nb23 djvulibre-lib-3.5.27 wayland-protocols-1.20 startup-notification-0.12nb3 dconf-0.36.0
py27-gtk2-2.24.0nb33 libdbusmenu-gtk3-12.10.2nb18 zenity-2.32.1nb29 libsoup-2.70.0nb2 libdbusmenu-glib-12.10.2nb9 libIDL-0.8.14nb5
glib-networking-2.64.3

78 packages to upgrade:
xmlto-0.0.28nb3 vala-0.48.7 tk-8.6.10 tiff-4.1.0 tcl-8.6.10nb2 rhash-1.4.0 rarian-0.8.1nb5 python37-3.7.8nb1 py37-six-1.15.0
py37-setuptools-44.1.1 py37-roman-3.3 py37-lxml-4.5.2 py37-libxml2-2.9.10nb1 py37-gobject3-3.36.1 py37-expat-3.7.8
py37-cElementTree-3.7.8 py27-setuptools-44.1.1 py27-gobject3-3.36.1 png-1.6.37 pcre2-10.35nb1 openjpeg-2.3.1nb3 nspr-4.27
ninja-build-1.10.0nb1 netpbm-10.79.04nb4 mpfr-4.0.2nb1 mozilla-rootcerts-1.0.20200529nb1 meson-0.55.0nb2 mate-screensaver-1.24.0nb1
mate-power-manager-1.24.1 mate-media-1.24.0nb1 mate-control-center-1.24.0nb1 mate-common-1.24.1 mate-calc-1.24.0nb1
mate-backgrounds-1.24.1 libwebp-1.1.0nb1 libspectre-0.2.9 libsecret-0.20.3 libpsl-0.21.1 libmatemixer-1.24.0nb1 libidn-1.36
libgpg-error-1.38 libgcrypt-1.8.6 libcups-2.3.3nb4 libappindicator-12.10.0nb5 lcms2-2.11 jpeg-9d jbigkit-2.1nb1 jbig2dec-0.18
hunspell-1.7.0nb2 help2man-1.47.16 harfbuzz-2.7.1 gssdp-1.0.3nb9 gnutls-3.6.14 gmp-6.2.0 glib2-tools-2.64.4 glib2-2.64.4
ghostscript-agpl-9.52nb2 ghostscript-9.05nb22 gettext-tools-0.21nb1 gettext-lib-0.21 gdbus-codegen-2.64.4 fribidi-1.0.10
exempi-2.5.0nb4 eom-1.24.0nb1 docbook-xsl-1.79.2nb3 dbus-1.12.20 cmake-3.18.1 caja-extensions-1.24.0nb2 caja-1.24.0nb1
boost-headers-1.73.0nb1 bison-3.4.2 bash-5.0.18 automake-1.16.2 atk-2.36.0 at-spi2-core-2.36.0 at-spi2-atk-2.34.2
osabi-NetBSD-9.99.69 gupnp-1.0.3nb7

1 package to install:
sqlite3-3.32.3

156 to refresh, 78 to upgrade, 1 to install
0B to download, 8014K to install

proceed ? [Y/n] y
refreshing xorg-util-macros-1.19.2...
Memory fault (core dumped)

$ gdb /usr/pkg/bin/pkgin ./pkgin.core
[...]
[New process 2371]
Core was generated by `pkgin'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 __flockfile_internal (internal=1, fp=0x0) at /home/source/ab/HEAD/src/lib/libc/stdio/flockfile.c:103
103 /home/source/ab/HEAD/src/lib/libc/stdio/flockfile.c: No such file or directory.
(gdb) bt
#0 __flockfile_internal (internal=1, fp=0x0) at /home/source/ab/HEAD/src/lib/libc/stdio/flockfile.c:103
#1 __flockfile_internal (fp=fp@entry=0x0, internal=internal@entry=1) at /home/source/ab/HEAD/src/lib/libc/stdio/flockfile.c:97
#2 0x00007774fd1657b3 in vfprintf (fp=0x0, fmt0=0x41a0b0 "---%s: %s", ap=ap@entry=0x7f7fff7f8748)
at /home/source/ab/HEAD/src/lib/libc/stdio/vfwprintf.c:554
#3 0x00007774fd15fb39 in fprintf (fp=, fmt=) at /home/source/ab/HEAD/src/lib/libc/stdio/fprintf.c:57
#4 0x0000000000404a1c in log_tag (fmt=0x41a18c "refreshing %s...\n") at actions.c:207
#5 0x0000000000404dc6 in do_pkg_install (installhead=0x7774fe9fe0c8) at actions.c:330
#6 0x0000000000405b98 in pkgin_install (opkgargs=0x7774fe12e000, do_inst=1, upgrade=1) at actions.c:672
#7 0x00000000004062ae in pkgin_upgrade (do_inst=1) at actions.c:901
#8 0x000000000040944f in main (argc=2, argv=0x7f7fff7fa048) at main.c:224

@jperkin
Copy link
Contributor

jperkin commented Aug 19, 2020

Thanks! Will look at this today.

FWIW there's no such thing as pkgin upgrade <package>, there's only the singular pkgin upgrade command to upgrade every package.

@jperkin jperkin self-assigned this Aug 19, 2020
@jperkin jperkin merged commit ab7204e into NetBSDfr:master Aug 20, 2020
@jperkin
Copy link
Contributor

jperkin commented Sep 1, 2020

It's also worth mentioning that, as described in #102, the -V flag actually does the complete opposite of what you expect!

@dhgutteridge
Copy link
Contributor Author

It's also worth mentioning that, as described in #102, the -V flag actually does the complete opposite of what you expect!

Yeah, once I actually used it, and looked at what it was doing, I was puzzled, because it wasn't what I thought I'd get. That was my first time really using pkgin for anything, so I wanted as much detail as possible about what it was doing. Anyway, good you've opened #102, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants