Bug 1632177

Summary: dnf segfault in libdnf::TransactionItem::saveReplacedBy()
Product: [Fedora] Fedora Reporter: Nerijus Baliūnas <nerijus>
Component: dnfAssignee: Daniel Mach <dmach>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: awilliam, dmach, klember, lruzicka, markus.linnala, mattdm, mblaha, nerijus, packaging-team-maint, peter.hutterer, robatino, rpm-software-management, vmukhame, zbyszek
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: AcceptedBlocker
Fixed In Version: dnf-4.0.4-1.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-22 16:13:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1517013    

Description Nerijus Baliūnas 2018-09-24 10:10:43 UTC
# LANG=C dnf distro-sync -v
Completion plugin: Generating completion cache...
--> Starting dependency resolution
Segmentation fault (core dumped)

# rpm -q dnf
dnf-3.5.1-1.fc29.noarch

# coredumpctl debug
           PID: 91743 (dnf)
           UID: 0 (root)
           GID: 0 (root)
        Signal: 11 (SEGV)
     Timestamp: Mon 2018-09-24 12:51:43 EEST (13s ago)
  Command Line: /usr/bin/python3 /usr/bin/dnf distro-sync -v
    Executable: /usr/bin/python3.7
 Control Group: /user.slice/user-1000.slice/session-2.scope
          Unit: session-2.scope
         Slice: user-1000.slice
       Session: 2
     Owner UID: 1000 (user)
       Boot ID: 5aab7f53580f4cbe9f543b262aaa786c
    Machine ID: 202fa4068aff1e3f55685fc30000001d
      Hostname: localhost.localdomain
       Storage: /var/lib/systemd/coredump/core.dnf.0.5aab7f53580f4cbe9f543b262aaa786c.91743.1537782703000000.lz4
       Message: Process 91743 (dnf) of user 0 dumped core.
                
                Stack trace of thread 91743:
                #0  0x00007fec447ed12b _ZN6libdnf15TransactionItem14saveReplacedByEv (libdnf.so.2)
                #1  0x00007fec447f9a4a _ZN6libdnf12swdb_private11Transaction9saveItemsEv (libdnf.so.2)
                #2  0x00007fec447f3582 _ZN6libdnf11Transformer14transformTransESt10shared_ptrI7SQLite3ES3_ (libdnf.so.2)
                #3  0x00007fec447f4c7e _ZN6libdnf11Transformer9transformEv (libdnf.so.2)
                #4  0x00007fec447de65b _ZN6libdnf4SwdbC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (libdnf.so.2)
                #5  0x00007fec4308f7df n/a (_transaction.so)
                #6  0x00007fec52571563 PyCFunction_Call (libpython3.7m.so.1.0)
                #7  0x00007fec5260f656 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #8  0x00007fec52551506 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #9  0x00007fec525527d7 _PyFunction_FastCallDict (libpython3.7m.so.1.0)
                #10 0x00007fec525619c6 _PyObject_Call_Prepend (libpython3.7m.so.1.0)
                #11 0x00007fec525b0011 n/a (libpython3.7m.so.1.0)
                #12 0x00007fec525c2eb9 _PyObject_FastCallKeywords (libpython3.7m.so.1.0)
                #13 0x00007fec5260ec05 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #14 0x00007fec525525fa _PyFunction_FastCallDict (libpython3.7m.so.1.0)
                #15 0x00007fec52571706 n/a (libpython3.7m.so.1.0)
                #16 0x00007fec525506a5 _PyObject_GenericGetAttrWithDict (libpython3.7m.so.1.0)
                #17 0x00007fec52609819 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #18 0x00007fec52551506 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #19 0x00007fec525527d7 _PyFunction_FastCallDict (libpython3.7m.so.1.0)
                #20 0x00007fec525619c6 _PyObject_Call_Prepend (libpython3.7m.so.1.0)
                #21 0x00007fec525b0011 n/a (libpython3.7m.so.1.0)
                #22 0x00007fec525c2eb9 _PyObject_FastCallKeywords (libpython3.7m.so.1.0)
                #23 0x00007fec5260e46e _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #24 0x00007fec525525fa _PyFunction_FastCallDict (libpython3.7m.so.1.0)
                #25 0x00007fec5257166e n/a (libpython3.7m.so.1.0)
                #26 0x00007fec525506a5 _PyObject_GenericGetAttrWithDict (libpython3.7m.so.1.0)
                #27 0x00007fec52609819 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #28 0x00007fec52551506 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #29 0x00007fec52598271 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #30 0x00007fec52609461 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #31 0x00007fec52551506 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #32 0x00007fec52598271 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #33 0x00007fec52609461 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #34 0x00007fec525980ca _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #35 0x00007fec5260961c _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #36 0x00007fec525980ca _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #37 0x00007fec5260961c _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #38 0x00007fec525980ca _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #39 0x00007fec5260961c _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #40 0x00007fec52551506 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #41 0x00007fec52598271 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #42 0x00007fec5260961c _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #43 0x00007fec52551506 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #44 0x00007fec52598271 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #45 0x00007fec5260a4ea _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #46 0x00007fec52551506 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #47 0x00007fec525524b3 PyEval_EvalCodeEx (libpython3.7m.so.1.0)
                #48 0x00007fec525524db PyEval_EvalCode (libpython3.7m.so.1.0)
                #49 0x00007fec52676ca2 n/a (libpython3.7m.so.1.0)
                #50 0x00007fec5267878a PyRun_FileExFlags (libpython3.7m.so.1.0)
                #51 0x00007fec52679988 PyRun_SimpleFileExFlags (libpython3.7m.so.1.0)
                #52 0x00007fec5267b20d n/a (libpython3.7m.so.1.0)
                #53 0x00007fec5267b6e0 _Py_UnixMain (libpython3.7m.so.1.0)
                #54 0x00007fec520e9413 __libc_start_main (libc.so.6)
                #55 0x000056500d00508e _start (python3.7)

GNU gdb (GDB) Fedora 8.2-2.fc29
...
Core was generated by `/usr/bin/python3 /usr/bin/dnf distro-sync -v'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fec447ed12b in libdnf::TransactionItem::saveReplacedBy() () from /lib64/libdnf.so.2
Missing separate debuginfos, use: dnf debuginfo-install python3-3.7.0-9.fc29.x86_64
(gdb) bt
#0  0x00007fec447ed12b in libdnf::TransactionItem::saveReplacedBy() () at /lib64/libdnf.so.2
#1  0x00007fec447f9a4a in libdnf::swdb_private::Transaction::saveItems() () at /lib64/libdnf.so.2
#2  0x00007fec447f3582 in libdnf::Transformer::transformTrans(std::shared_ptr<SQLite3>, std::shared_ptr<SQLite3>) () at /lib64/libdnf.so.2
#3  0x00007fec447f4c7e in libdnf::Transformer::transform() () at /lib64/libdnf.so.2
#4  0x00007fec447de65b in libdnf::Swdb::Swdb(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
    at /lib64/libdnf.so.2
#5  0x00007fec4308f7df in  () at /usr/lib64/python3.7/site-packages/libdnf/_transaction.so
#6  0x00007fec52571563 in PyCFunction_Call () at /lib64/libpython3.7m.so.1.0
#7  0x00007fec5260f656 in _PyEval_EvalFrameDefault () at /lib64/libpython3.7m.so.1.0
#8  0x00007fec52551506 in _PyEval_EvalCodeWithName () at /lib64/libpython3.7m.so.1.0
#9  0x00007fec525527d7 in _PyFunction_FastCallDict () at /lib64/libpython3.7m.so.1.0
#10 0x00007fec525619c6 in _PyObject_Call_Prepend () at /lib64/libpython3.7m.so.1.0

Cannot install debuginfo neither:
# dnf debuginfo-install python3-3.7.0-9.fc29.x86_64
...
Segmentation fault (core dumped)

dnf clean all did not help.

Comment 1 Daniel Mach 2018-09-24 11:39:18 UTC
Could you provide the core dump and also ideally contents of the /var/lib/dnf/ directory so we can reproduce the problem?

Comment 3 Nerijus Baliūnas 2018-09-27 06:26:41 UTC
dnf started to work after deleting /var/lib/dnf directory.

Comment 4 Markus Linnala 2018-09-29 18:46:53 UTC
I got essentially same dump when trying to do 'dnf check-update' or 'dnf update' etc.

Deleting /var/lib/dnf directory solved the problem for me too.

I got this problem with f29 beta version of dnf and then I upgraded it by hand from koji without any progress and current versions are:

dnf-plugins-core-3.0.4-1.fc29.noarch
python3-dnf-plugins-extras-common-3.0.1-1.fc29.noarch
python3-dnf-plugin-leaves-3.0.4-1.fc29.noarch
python3-dnf-plugin-versionlock-3.0.4-1.fc29.noarch
dnfdragora-updater-1.0.1-13.git20180108.b0e8a66.fc29.noarch
dnf-3.6.1-1.fc29.noarch
etckeeper-dnf-1.18.8-1.fc29.noarch
libdnf-debuginfo-0.20.0-1.fc29.x86_64
dnf-automatic-3.6.1-1.fc29.noarch
dnf-utils-3.0.4-1.fc29.noarch
dnfdaemon-0.3.19-4.fc29.noarch
python3-dnf-3.6.1-1.fc29.noarch
python3-dnf-plugins-core-3.0.4-1.fc29.noarch
python3-dnfdaemon-0.3.19-4.fc29.noarch
python3-dnf-plugin-rpmconf-3.0.1-1.fc29.noarch
libdnf-0.20.0-1.fc29.x86_64
dnfdragora-1.0.1-13.git20180108.b0e8a66.fc29.noarch
python3-libdnf-0.20.0-1.fc29.x86_64
python3-dnf-plugin-local-3.0.4-1.fc29.noarch
libdnf-debugsource-0.20.0-1.fc29.x86_64
python3-dnf-plugin-system-upgrade-3.0.1-1.fc29.noarch
dnfdaemon-selinux-0.3.19-4.fc29.noarch
dnf-data-3.6.1-1.fc29.noarch

Comment 5 Peter Hutterer 2018-10-11 23:14:47 UTC
Just ran into this too after a a dnf system-upgrade to f29. Deleting /var/lib/dnf did the trick, before that all dnf operations failed with the above stacktrace.

$ rpm -qa | grep dnf
libdnf-0.20.0-1.fc29.x86_64
python3-dnf-plugins-core-3.0.4-1.fc29.noarch
python2-dnf-plugins-extras-common-3.0.2-1.fc29.noarch
dnf-yum-4.0.3.6.1-2.fc29.noarch
dnf-3.6.1-2.fc29.noarch
python3-dnf-plugins-extras-common-3.0.2-1.fc29.noarch
python3-dnf-plugin-system-upgrade-3.0.2-1.fc29.noarch
python3-libdnf-0.20.0-1.fc29.x86_64
python2-dnf-3.6.1-2.fc29.noarch
python2-libdnf-0.20.0-1.fc29.x86_64
dnf-automatic-3.6.1-2.fc29.noarch
dnf-data-3.6.1-2.fc29.noarch
dnf-plugins-core-3.0.4-1.fc29.noarch
python3-dnf-3.6.1-2.fc29.noarch

I still have the /var/lib/dnf directory for now, let me know if you need it for debugging.

Comment 6 Adam Williamson 2018-10-11 23:22:44 UTC
Seems worth considering as a Final blocker, we really do not want people who upgrade to F29 hitting this.

Comment 7 Matthew Miller 2018-10-12 02:38:02 UTC
+1 blocker

Comment 8 Kalev Lember 2018-10-12 07:15:38 UTC
+1 blocker

Comment 9 Lukas Ruzicka 2018-10-12 12:39:09 UTC
I agree with comments 6,7,8.

Comment 10 Adam Williamson 2018-10-12 15:09:38 UTC
Marking accepted, then.

Comment 11 Adam Williamson 2018-10-12 15:33:39 UTC
dmach, tomasz torcz suggests 1600917 is probably the same bug as this; can you check and close one as a dupe of the other (doesn't really matter which way around, it's up to you) if you agree? Thanks!

Comment 12 Daniel Mach 2018-10-17 10:48:37 UTC
Yes, it's a duplicate.

I've created a fix that avoids the crash:
https://github.com/rpm-software-management/libdnf/pull/614

We'll need more time for a proper patch, but that can be done after F29 release.

Comment 13 Fedora Update System 2018-10-17 13:34:35 UTC
dnf-4.0.4-1.fc29 dnf-plugins-core-4.0.0-2.fc29 libdnf-0.22.0-2.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2018-2789f6b6e7

Comment 14 Fedora Update System 2018-10-17 23:31:09 UTC
dnf-4.0.4-1.fc29, dnf-plugins-core-4.0.0-2.fc29, libdnf-0.22.0-2.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-2789f6b6e7

Comment 15 Lukas Ruzicka 2018-10-18 09:31:01 UTC
The update solved the problem. The above mentioned commands do not traceback anymore and the operation completes. Verified.

Comment 16 Fedora Update System 2018-10-18 14:07:07 UTC
anaconda-29.24.6-1.fc29 dnf-4.0.4-1.fc29 dnf-plugins-core-4.0.0-2.fc29 libblockdev-2.20-2.fc29 libdnf-0.22.0-2.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2018-2789f6b6e7

Comment 17 Fedora Update System 2018-10-20 19:22:39 UTC
anaconda-29.24.7-1.fc29, dnf-4.0.4-1.fc29, dnf-plugins-core-4.0.0-2.fc29, libblockdev-2.20-2.fc29, libdnf-0.22.0-5.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-2789f6b6e7

Comment 18 Fedora Update System 2018-10-22 16:13:38 UTC
anaconda-29.24.7-1.fc29, dnf-4.0.4-1.fc29, dnf-plugins-core-4.0.0-2.fc29, libblockdev-2.20-2.fc29, libdnf-0.22.0-5.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.