Bug 38642 - SegFault при удалении пакета с пустым тегом Arch
Summary: SegFault при удалении пакета с пустым тегом Arch
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: libapt (show other bugs)
Version: unstable
Hardware: x86_64 Linux
: P5 major
Assignee: Ivan Zakharyaschev
QA Contact: qa-sisyphus
URL:
Keywords:
: 38381 (view as bug list)
Depends on:
Blocks: 41405
  Show dependency tree
 
Reported: 2020-06-25 19:49 MSK by Vitaly Lipatov
Modified: 2022-04-17 17:51 MSK (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vitaly Lipatov 2020-06-25 19:49:51 MSK
sudo gdb --args apt-get remove python-module-coverage-test-runner libarpack-devel libgcj_bc1 xorg-mesagl libprotobuf15-lite rpm-build-java-maven-fragments wdfs perl-HTML-Format libboost_atomic1.67.0 msp430-gcc libboost_container1.67.0 python-module-fs libdvdread-debuginfo libboost_program_options1.67.0 libv8-nodejs libboost_random1.71.0 microdc2 liboop-devel python-module-lazy_object_proxy libboost_regex1.67.0 soprano-common python-module-dialog backport-util-concurrent msodbcsql17 libboost_random1.72.0 percona-xtrabackup python-module-zope.deprecation libkpathsea python-module-ceph_disk mingw32-pthreads libgsl0.17 jaffl python-module-zc.lockfile python-module-scapy-ssl_tls libboost_graph_parallel1.71.0 libboost_type_erasure1.67.0 sisu-plexus-metadata openmpi-compat libjson-c4 libboost_filesystem1.67.0 google-perftools shedskin libboost_numpy3-1.71.0 python3-module-ZEO python-module-logilab-common mojo-signatures libboost_graph_parallel1.72.0 pear-PHPUnit_MockObject libdockapp python-module-Pyrex fonts-ttf-reduce libboost_numpy3-1.72.0 libUCan2 python3-module-minify libboost_test1.71.0 libgpgme-pthread11 python-module-scapy libnm-util2 python-module-pyogg node-leveldown python-module-glob2 libboost_log1.67.0 libsetools python-module-click-plugins libboost_test1.72.0 saxon9-xpath pear-Text_Template mingw32-iconv sisu-bean-scanners python-module-zope.browser google-gadgets-common python3-module-ZODB-tests python-module-pygtk_git-devel-data python-module-dogpile.cache gnome-mime-data libboost_iostreams1.71.0 libqpdf libmpfr4 libarpack python-module-cheetah i586-libnettle7 libboost_iostreams1.72.0 pike7.6-math libnetpbm10 oss-parent pear-PHPUnit_Selenium msp430mcu python3-module-zope.pagetemplate mingw32-cpp python3-module-zope.browserresource pike7.6-GL libboost_fiber1.67.0 libCoinOsi python-module-pyvorbis libboost_stacktrace1.67.0 python3-module-yuicompressor libgnomeprint libvtk6.2 libdvdread asm2 libboost_thread1.67.0 libossp-uuid libgcrypt11 mingw32-libxml2 python3-module-ceph_detect_init libdcmtk14 i586-libhogweed5 libboost_serialization1.67.0 sakura python-module-flask-cache mingw32-pkg-config python-module-Levenshtein sisu-plexus-shim python-module-barenecessities libboost_math_c99l1.71.0 python-module-zope.tal libboost_date_time1.67.0 libshout-devel gtk2-theme-ClearlooksClassic mingw32-gcc rpm-build-php-version libboost_contract1.67.0 libboost_math_c99l1.72.0 python3-module-zope.traversing saxon9 arduino python-module-mail sisu-osgi-registry libpilot-link-devel pike7.6-devel libggadget-dbus libboost_python1.67.0 mingw32-libxml2-static pear-PHP_Timer plexus-container-default mingw32-nsis mingw32-expat easymock2 perl-encoding-warnings libboost_mpi_python3-1.72.0 pike7.6-postgres packages-info-i18n-common python-module-fonttools openexr6-common pear-DbUnit gst-plugins-good libdcmtk axis libcrl-devel libboost_chrono1.71.0 libclamav7 python-module-ceph-argparse telegram-cli libboost_math_c991.71.0 libboost_math_tr11.71.0 mingw32-wxGTK chromium-browser-flashblock libxerces-c31 saxon9-dom libvde2.2 python-module-requests-unixsocket libboost_numpy1.67.0 libv8-nodejs-devel libboost_math_c991.72.0 libboost_mpi1.71.0 libboost_math_tr11.72.0 sisu-inject-bean ilmbase6-common libjson-c sipgateway-doc libdsk-devel talk python-module-setools libboost_graph1.67.0 jboss-interceptor gpgme17-common lxde-lxnm libboost_mpi1.72.0 sipgateway-devel pike7.6-krb5 python-module-argparse_tools pear-PEAR_Command_Packaging rpm-macros-wine libboost_math_c99f1.67.0 mingw32-libffi python-module-gst libboost_locale1.67.0 llvm6.0 libjson-c4-debuginfo pike7.6-bzip2 mingw32-gettext-static bcel5.3 varkon gksu xmldb-api sisu-plexus-scanners libjson libboost_math_tr1l1.71.0 libvde-devel sisu-inject-plexus python3-module-ZODB libnm-glib4 python-module-cliapp libboost_coroutine1.71.0 python3-module-ceph_disk libboost_math_tr1l1.72.0 pear-PHP_CodeCoverage llvm6.0-libs excalibur python-module-ceph_detect_init CoinSample-data libboost_timer1.71.0 python-module-zope.deferredimport google-gadgets-core html-xml-utils pike7.6 libboost_mpi_python1.72.0 libboost_context1.67.0 libmetacity mingw32-wxGTK-static mingw32-binutils python-module-kid fpc-docs mingw32-runtime mingw32-dlfcn rpm-build-mingw32 metacity-theme-simple pssh libass5 libggadget-webkitjs libgssdp python-module-Pyrex-pickles tomcat6-servlet-2.5-api xfce4-wmdock-plugin rpm-macros-desktop-file-utils pike7.6-sane indexhtml-small_business gx python-module-zodbpickle libboost_atomic1.71.0 fonts-ttf-java-1.6.0-sun pike-common libgda4 libboost_container1.71.0 pike7.6-zlib sisu-plexus-binders python-module-ttystatus libboost_signals1.67.0 maven2-common-poms sisu-bean-containers libboost_program_options1.71.0 libCharLS libboost_container1.72.0 libgstreamer libisl13 java-sun-desktop python3-module-zope.browserpage itk libgupnp libboost_regex1.71.0 python-module-zdaemon libboost_program_options1.72.0 libshout libboost_math_tr1f1.67.0 libopenjpeg ruby-abstract_type python-module-bugzilla libcdio12 libboost_python3-1.67.0 mingw32-libogg libboost_regex1.72.0 mingw32-dbus libnettle7-debuginfo libggadget-xdg python-module-pygnome-gtksourceview python3-module-zope.contentprovider i586-clang6.0-libs libboost_type_erasure1.71.0 python-module-4Suite-XML libboost_filesystem1.71.0 libboost_wave1.67.0 libminisat libboost_system1.67.0 mingw32-libpng gstreamer-utils mingw32-w32api libnet-snmp30 libprotobuf14 libprotobuf15 libprotobuf17 python-module-blist libConsoleKit2 libraptor outwiker design-graphics-sisyphus2 python-module-sql hg-fast-export gpg-pubkey libibcommon python-module-zope.schema libboost_log1.71.0 ruby-yui-compressor python-module-pygtk_git gnome-themes-default-common mingw32-libjpeg sisu-spi-registry menu-devel libgnomecups nvidia_glx_340.98 python-module-portend maven-ant-tasks libboost_random1.67.0 ilmbase11-common msp430-binutils python-module-hg-github python-module-zope.size python-module-zope.dottedname libggadget itcl libgtkhtml4 boost-serialization libnettle6 libnettle7 libboost_graph_parallel1.67.0 libgmp3 libboost_fiber1.71.0 libboost_numpy3-1.67.0 python-module-pyclipper python-module-zope.contenttype libcrl sublime-text libboost_stacktrace1.71.0 python-module-zope.proxy libtgl-devel python-module-zope.tales jbosgi-deployment libsynctex1 python-module-pywebdav libboost_fiber1.72.0 libtorrent-rasterbar9 libvtk6.2-tcl openexr21-common libboost_thread1.71.0 libcloog-isl4 libboost_test1.67.0 libdsk python-module-pyScss libboost_stacktrace1.72.0 clang6.0-libs python-module-prometheus_client libgoom libopencv3.4 libibcommon-devel libgda4-devel gnome-theme-clearlooks libboost_serialization1.71.0 python-module-jsonpatch python-module-txaio-pickles metacity python-module-events pear-File_Iterator libboost_date_time1.71.0 libtidy libboost_serialization1.72.0 libgoom-devel libgypsy python-module-jsonpointer libboost_contract1.71.0 xorg-compat-devel libggadget-js sisu-bean-locators libhogweed4 libhogweed5 libboost_date_time1.72.0 i586-llvm6.0-libs mingw32-readline classworlds glassfish-jstl libgd2 sim-common pear-PHP_TokenStream libboost_iostreams1.67.0 CoinNetlib-data libboost_python1.71.0 libgtksourceview1 openmpi-lib-compat shunit2 libboost_python1.72.0 arduino-core llvm4.0-libs python-module-ed25519 pike7.6-doc mingw32-zlib pam-ck-connector2 librrd4 apache-juddi sisu-bean-converters mingw32-libltdl python-module-pylzma libpilot-link gtkrawgallery curator libavutil52 genbackupdata sisu-bean-reflect libmbedtls10 libmbedtls11 libboost_numpy1.71.0 mingw32-glib2 libgps22 xpp2 libgupnp-debuginfo libboost_graph1.71.0 mingw32-sqlite libboost_math_c99l1.67.0 icdiff libboost_numpy1.72.0 python-module-py2pack libqrencode CoinMiplib3-data libclucene raptor libgssdp-debuginfo python-module-conversionkit python-module-libnacl libpoppler85 libpoppler86 libpoppler89 w3c-markup-validator-libs mingw32-gettext libpoppler90 libpoppler91 libpoppler94 libboost_graph1.72.0 jenkins libmcs i586-libgd2 mingw32-termcap xfce4-quicklauncher-plugin libboost_math_c99f1.71.0 python3-module-ZODB3 libjsoncpp1 libboost_locale1.71.0 python-module-pydenticon maven-error-diagnostics deepsolver python-module-relatorio python-module-zope.configuration libboost_math_c99f1.72.0 sisu-bean-inject python-module-wget branding-altlinux-backup-server-graphics libx265-130 libx265-160 pear-PHP_CodeSniffer liboop mingw32-gcc-c++ libots libboost_chrono1.67.0 python3-module-zdaemon libnet-snmp30-snmptrapd itk-devel python-module-IPy jbosgi-spi libCoinUtils libxmlrpcxx libboost_math_c991.67.0 libboost_math_tr11.67.0 xmldb-api-sdk libboost_context1.71.0 jbosgi-resolver1 msp430-libc libboost_mpi1.67.0 libgst-plugins libxfcegui4 python-module-zope.filerepresentation sisu-plexus-lifecycles python-module-ydbf libboost_context1.72.0 python-module-identicon lib765 python-module-pyaml jbosgi-metadata libhogweed5-debuginfo libmcs-devel sipgateway alt-docs-main python-module-pycairo-common-devel jbosgi-vfs python-module-zope.lifecycleevent udev_static-addon libvpx3 libvpx4 libots-devel libtgl pike7.6-gdbm ZendFramework lib765-devel libvtk6.2-python libboost_math_tr1l1.67.0 sisu-plexus-locators teamviewer i586-libnettle6 emacs-git libboost_coroutine1.67.0 python-module-signedjson mingw32-openssl hibernate libclipper libelogind libboost_mpi_python1.67.0 mingw32-libtiff libboost_math_tr1f1.71.0 libboost_timer1.67.0 jbosgi-resolver golang-github-golang-protobuf-devel libboost_python3-1.71.0 libvpx python-module-cmd2 libmbedcrypto1 pike7.6-GLUT libboost_math_tr1f1.72.0 sisu-plexus-converters libdeepsolver libboost_python3-1.72.0 pike7.6-sdl libboost_wave1.71.0 oniguruma libboost_system1.71.0 i586-libhogweed4 sisu-bean-binders libqpdf21 libqpdf26
Dwarf Error: wrong version in compilation unit header (is 1024, should be 2, 3, 4 or 5) [in module /usr/lib/debug/lib64/libm-2.30.so.debug]



Program received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
65		VPCMPEQ (%rdi), %ymm0, %ymm1
(gdb) bt
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
#1  0x00007ffff7ede54a in std::char_traits<char>::length (__s=0x0) at /usr/include/c++/8/bits/char_traits.h:322
#2  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::append (__s=0x0, this=0x7fffffff6f60) at /usr/include/c++/8/bits/basic_string.h:1266
#3  std::operator+<char, std::char_traits<char>, std::allocator<char> > (__rhs=0x0, __lhs=...) at /usr/include/c++/8/bits/basic_string.h:6030
#4  (anonymous namespace)::rpm_name_conversion (Pkg=...) at rpm/rpmpm.cc:84
#5  0x00007ffff7edf72c in pkgRPMPM::Go (this=0x37b0a40) at rpm/rpmpm.cc:310
#6  0x00007ffff7f1bac5 in pkgPackageManager::DoInstall (this=0x37b0a40) at packagemanager.cc:672
#7  0x000000000040f269 in ?? ()
#8  0x0000000000412152 in ?? ()
#9  0x00007ffff7eb0b7e in CommandLine::DispatchArg (this=0x7fffffff7f90, Map=<optimized out>, NoMatch=<optimized out>) at contrib/cmndline.cc:359
#10 0x0000000000408406 in ?? ()
#11 0x00007ffff7ccfe1b in __libc_start_main (main=0x407e70, argc=535, argv=0x7fffffff89d8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffff89c8) at ../csu/libc-start.c:308
#12 0x000000000040876a in ?? ()
(gdb) break Quit
(gdb) q
A debugging session is active.

	Inferior 1 [process 3033946] will be killed.


rpm/rpmpm.cc:84:
Name = Name + "." + Pkg.CurrentVer().Arch();
Comment 1 Vitaly Lipatov 2020-06-25 19:58:19 MSK
...
> rpm/rpmpm.cc:84:
> Name = Name + "." + Pkg.CurrentVer().Arch();

Предполагаю, что падение из-за реализации Arch(), которая способна вернуть 0:

pkgCache::VerIterator::Arch (this=<optimized out>, this=<optimized out>) at ../include/apt-pkg/cacheiterators.h:137
137	   inline const char *Arch() const {return Ver->Arch == 0?0:Owner->StrP + Ver->Arch;};

С помощью 
$ rpm -q --queryformat "%{name}:%{ARCH}\n"
выявил пакет с незаполненным ARCH, это оказался

$ rpm -qi gpg-pubkey
Name        : gpg-pubkey
Version     : df7587c3
Release     : 576a5c23
Architecture: (none)
Install Date: Вс 10 дек 2017 16:32:01
Group       : Public Keys
Size        : 0
License     : pubkey
Signature   : (none)
Source RPM  : (none)
Build Date  : Ср 22 июн 2016 12:36:35
Build Host  : localhost
Relocations : (not relocatable)
Packager    : Skype Linux Client Repository <se-um@microsoft.com>
Summary     : gpg(Skype Linux Client Repository <se-um@microsoft.com>)

apt-get remove gpg-pubkey
давало падение, так что удалил его через rpm -e
и проблема ушла.

Вывод: надо бы добавить проверку на пустой Arch() перед прибавлением к Name + "." + ...
Comment 2 Anton Farygin 2020-06-25 23:54:23 MSK
Это поведение уже давным давно исправлено уже даже не знаю в каком баге и коммите.

Ждём нового apt от ментейнеров.
Comment 3 Aleksei Nikiforov 2020-06-26 10:31:48 MSK
(In reply to Vitaly Lipatov from comment #1)
> ...

(In reply to Anton Farygin from comment #2)
> Это поведение уже давным давно исправлено уже даже не знаю в каком баге и
> коммите.
> 
> Ждём нового apt от ментейнеров.

Всё верно. Проблема в пакете gpg-pubkey, который создаётся командой rpm --import ${gpg_key_filename}. Патч также был давно предложен мэйнтейнерам apt:

https://lists.altlinux.org/pipermail/devel/2020-January/209748.html
Comment 4 Vitaly Lipatov 2020-10-30 20:20:11 MSK
(Ответ для Aleksei Nikiforov на комментарий #3)
> (In reply to Vitaly Lipatov from comment #1)
> > ...
> 
> (In reply to Anton Farygin from comment #2)
> > Это поведение уже давным давно исправлено уже даже не знаю в каком баге и
> > коммите.
> > 
> > Ждём нового apt от ментейнеров.
> 
> Всё верно. Проблема в пакете gpg-pubkey, который создаётся командой rpm
> --import ${gpg_key_filename}. Патч также был давно предложен мэйнтейнерам
> apt:
> 
> https://lists.altlinux.org/pipermail/devel/2020-January/209748.html
А мэйнтейнеры apt не могут принимать короткие багфиксы?
Comment 5 Ivan Zakharyaschev 2021-07-01 13:51:13 MSK
*** Bug 38381 has been marked as a duplicate of this bug. ***
Comment 6 Ivan Zakharyaschev 2021-07-01 13:58:41 MSK
Спасибо!

В 0.5.15lorg2-alt72 исправляется.

И есть тест http://git.altlinux.org/gears/a/apt.git?p=apt.git;a=blob;f=test/integration/test-apt-remove-gpg-pubkey;h=ccfc5530f0b8e5d03b4fb94f798a3a9cfd9341c1;hb=HEAD :

#!/bin/bash
set -eu

TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework

if [ -z "${APT_TEST_GPGPUBKEY}" ]; then
	msgskip
	exit 0
fi

setupenvironment

testpkginstalled 'gpg-pubkey'
testsuccess aptget -y remove 'gpg-pubkey'
testpkgnotinstalled 'gpg-pubkey'


который включен, если при запуске тестов в переменной APT_TEST_GPGPUBKEY передать путь к ключу для предварительного импорта в setupenvironment().
Comment 7 Ivan Zakharyaschev 2021-07-01 14:53:33 MSK
(In reply to Ivan Zakharyaschev from comment #6)
> Спасибо!
> 
> В 0.5.15lorg2-alt72 исправляется.

http://git.altlinux.org/gears/a/apt.git?p=apt.git;a=commitdiff;h=8f8259650bf3bd660710da31d872791d1fbca61e

commit 8f8259650bf3bd660710da31d872791d1fbca61e
Author: Aleksei Nikiforov <darktemplar@altlinux.org>
Date:   Fri Jan 31 10:24:42 2020 +0300

    Fix crash when removing 3rd-party packages with some tags missing (ALT#38381, ALT#38642)
    
    (cherry picked from commit 5395de392b261c394da31fe41c8a949a60b83277)

diff --git a/apt-pkg/rpm/rpmpm.cc b/apt-pkg/rpm/rpmpm.cc
index b1da515bd..287de77e2 100644
--- a/apt-pkg/rpm/rpmpm.cc
+++ b/apt-pkg/rpm/rpmpm.cc
@@ -67,7 +67,14 @@ std::string rpm_name_conversion(const pkgCache::PkgIterator &Pkg)
 
    // This is needed for removal to work on multilib packages, but old
    // rpm versions don't support name.arch in RPMDBI_LABEL, oh well...
-   Name = Name + "." + Pkg.CurrentVer().Arch();
+   {
+      const char * const Arch = Pkg.CurrentVer().Arch();
+
+      // Note: some 3rd-party packages may still miss arch, so only use it
+      // when it's present
+      if (Arch && *Arch)
+         Name = Name + "." + Arch;
+   }
 
    return Name;
 }
diff --git a/test/integration/test-apt-remove-gpg-pubkey b/test/integration/test-apt-remove-gpg-pubkey
index dcf0a04a4..ccfc5530f 100755
--- a/test/integration/test-apt-remove-gpg-pubkey
+++ b/test/integration/test-apt-remove-gpg-pubkey
@@ -1,8 +1,6 @@
 #!/bin/bash
 set -eu
 
-APT_TEST_XFAIL=YES
-
 TESTDIR=$(readlink -f $(dirname $0))
 . $TESTDIR/framework
Comment 8 nbr 2021-07-15 13:34:08 MSK
Хорошо бы добавить тест на все поля, которые не должны быть null, если они есть.