Comment 8 for bug 1512322

This also happened to me when upgrading from 17.10 to 18.04 here's the relevant bit of the upgrade log files:

2018-01-05 15:22:34,603 DEBUG failed to SystemUnLock() (E:Not locked)
2018-01-05 15:38:49,081 ERROR got an error from dpkg for pkg: 'systemd': 'triggers looping, abandoned'
2018-01-05 15:38:49,081 DEBUG running apport_pkgfailure() systemd: triggers looping, abandoned
2018-01-05 15:40:02,214 ERROR Exception during pm.DoInstall()
Traceback (most recent call last):
  File "/tmp/ubuntu-release-upgrader-1fsoxbon/DistUpgrade/", line 218, in run
    res = pm.do_install(self.writefd)
apt_pkg.Error: E:Sub-process /usr/bin/dpkg exited unexpectedly
2018-01-05 15:40:02,265 ERROR SystemError from cache.commit(): installArchives() failed
2018-01-05 15:40:02,265 ERROR found exception: 'E:Sub-process /usr/bin/dpkg exited unexpectedly'

Setting up gstreamer1.0-plugins-bad:amd64 (1.12.4-2ubuntu1) ...^M
dpkg: ../../src/packages.c:245: process_queue: Assertion `dependtry <= 4' failed.^M