Scroll Top
Evotec Services sp. z o.o., ul. Drozdów 6, Mikołów, 43-190, Poland

UniFi Controller upgrade on Ubuntu fails during package installation

Ubiquiti

We're a huge fan of Ubiquity hardware, especially it's UniFi products line. It's nice, modern hardware with lots of functionalities but also an easy to use software on top of it. One of the things that are done frequently is updating server version of UniFi to it's latest version.

This is pretty standard procedure: apt updateapt upgrade and done procedure.

Problem Description

During last update from version 5.5.19-9547 to 5.5.20-9565 for  some weird reason things didn't seem like going too well for an upgrade.

When executing standard procedure:

root@Evo:~# apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  unifi
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/159 MB of archives.
After this operation, 32.8 kB disk space will be freed.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 112164 files and directories currently installed.)
Preparing to unpack .../unifi_5.5.20-9565_all.deb ...
Previous setting (UniFi 5.5.19) is found.
dpkg: error processing archive /var/cache/apt/archives/unifi_5.5.20-9565_all.deb (--unpack):
 subprocess new pre-installation script returned error exit status 2
abort-upgrade: please reinstall previous version

sudo apt-get install --reinstall unifi=5.5.19-9547

*** Error in `/usr/bin/dpkg': munmap_chunk(): invalid pointer: 0x000056407b494f89 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7908b)[0x7f8f5ed9908b]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x1f8)[0x7f8f5eda6ed8]
/usr/bin/dpkg(+0x20cd0)[0x56407aaf1cd0]
/usr/bin/dpkg(+0x21119)[0x56407aaf2119]
/usr/bin/dpkg(+0x283cd)[0x56407aaf93cd]
/usr/bin/dpkg(+0x17737)[0x56407aae8737]
/usr/bin/dpkg(+0x17d00)[0x56407aae8d00]
/usr/bin/dpkg(+0xb26d)[0x56407aadc26d]
/usr/bin/dpkg(+0x20c0b)[0x56407aaf1c0b]
/usr/bin/dpkg(+0x20e01)[0x56407aaf1e01]
/usr/bin/dpkg(+0xa962)[0x56407aadb962]
/usr/bin/dpkg(+0x72fd)[0x56407aad82fd]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f8f5ed403f1]
/usr/bin/dpkg(+0x743a)[0x56407aad843a]
======= Memory map: ========
56407aad1000-56407ab16000 r-xp 00000000 fd:00 17563653                   /usr/bin/dpkg
56407ad16000-56407ad19000 r--p 00045000 fd:00 17563653                   /usr/bin/dpkg
56407ad19000-56407ad1a000 rw-p 00048000 fd:00 17563653                   /usr/bin/dpkg
56407ad1a000-56407af2e000 rw-p 00000000 00:00 0
56407b456000-56407c81e000 rw-p 00000000 00:00 0                          [heap]
7f8f5da0e000-7f8f5da24000 r-xp 00000000 fd:00 27525700                   /lib/x86_64-linux-gnu/libgcc_s.so.1
7f8f5da24000-7f8f5dc23000 ---p 00016000 fd:00 27525700                   /lib/x86_64-linux-gnu/libgcc_s.so.1
7f8f5dc23000-7f8f5dc24000 r--p 00015000 fd:00 27525700                   /lib/x86_64-linux-gnu/libgcc_s.so.1
7f8f5dc24000-7f8f5dc25000 rw-p 00016000 fd:00 27525700                   /lib/x86_64-linux-gnu/libgcc_s.so.1
7f8f5dc25000-7f8f5de4b000 rw-p 00000000 00:00 0
7f8f5de4b000-7f8f5de56000 r-xp 00000000 fd:00 27528433                   /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f8f5de56000-7f8f5e055000 ---p 0000b000 fd:00 27528433                   /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f8f5e055000-7f8f5e056000 r--p 0000a000 fd:00 27528433                   /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f8f5e056000-7f8f5e057000 rw-p 0000b000 fd:00 27528433                   /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f8f5e057000-7f8f5e05d000 rw-p 00000000 00:00 0
7f8f5e05d000-7f8f5e068000 r-xp 00000000 fd:00 27528435                   /lib/x86_64-linux-gnu/libnss_nis-2.24.so
7f8f5e068000-7f8f5e267000 ---p 0000b000 fd:00 27528435                   /lib/x86_64-linux-gnu/libnss_nis-2.24.so
7f8f5e267000-7f8f5e268000 r--p 0000a000 fd:00 27528435                   /lib/x86_64-linux-gnu/libnss_nis-2.24.so
7f8f5e268000-7f8f5e269000 rw-p 0000b000 fd:00 27528435                   /lib/x86_64-linux-gnu/libnss_nis-2.24.so
7f8f5e269000-7f8f5e27f000 r-xp 00000000 fd:00 27528429                   /lib/x86_64-linux-gnu/libnsl-2.24.so
7f8f5e27f000-7f8f5e47e000 ---p 00016000 fd:00 27528429                   /lib/x86_64-linux-gnu/libnsl-2.24.so
7f8f5e47e000-7f8f5e47f000 r--p 00015000 fd:00 27528429                   /lib/x86_64-linux-gnu/libnsl-2.24.so
7f8f5e47f000-7f8f5e480000 rw-p 00016000 fd:00 27528429                   /lib/x86_64-linux-gnu/libnsl-2.24.so
7f8f5e480000-7f8f5e482000 rw-p 00000000 00:00 0
7f8f5e482000-7f8f5e48a000 r-xp 00000000 fd:00 27528431                   /lib/x86_64-linux-gnu/libnss_compat-2.24.so
7f8f5e48a000-7f8f5e689000 ---p 00008000 fd:00 27528431                   /lib/x86_64-linux-gnu/libnss_compat-2.24.so
7f8f5e689000-7f8f5e68a000 r--p 00007000 fd:00 27528431                   /lib/x86_64-linux-gnu/libnss_compat-2.24.so
7f8f5e68a000-7f8f5e68b000 rw-p 00008000 fd:00 27528431                   /lib/x86_64-linux-gnu/libnss_compat-2.24.so
7f8f5e68b000-7f8f5e6a3000 r-xp 00000000 fd:00 27528438                   /lib/x86_64-linux-gnu/libpthread-2.24.so
7f8f5e6a3000-7f8f5e8a3000 ---p 00018000 fd:00 27528438                   /lib/x86_64-linux-gnu/libpthread-2.24.so
7f8f5e8a3000-7f8f5e8a4000 r--p 00018000 fd:00 27528438                   /lib/x86_64-linux-gnu/libpthread-2.24.so
7f8f5e8a4000-7f8f5e8a5000 rw-p 00019000 fd:00 27528438                   /lib/x86_64-linux-gnu/libpthread-2.24.so
7f8f5e8a5000-7f8f5e8a9000 rw-p 00000000 00:00 0
7f8f5e8a9000-7f8f5e8ac000 r-xp 00000000 fd:00 27528425                   /lib/x86_64-linux-gnu/libdl-2.24.so
7f8f5e8ac000-7f8f5eaab000 ---p 00003000 fd:00 27528425                   /lib/x86_64-linux-gnu/libdl-2.24.so
7f8f5eaab000-7f8f5eaac000 r--p 00002000 fd:00 27528425                   /lib/x86_64-linux-gnu/libdl-2.24.so
7f8f5eaac000-7f8f5eaad000 rw-p 00003000 fd:00 27528425                   /lib/x86_64-linux-gnu/libdl-2.24.so
7f8f5eaad000-7f8f5eb1f000 r-xp 00000000 fd:00 27525243                   /lib/x86_64-linux-gnu/libpcre.so.3.13.3
7f8f5eb1f000-7f8f5ed1e000 ---p 00072000 fd:00 27525243                   /lib/x86_64-linux-gnu/libpcre.so.3.13.3
7f8f5ed1e000-7f8f5ed1f000 r--p 00071000 fd:00 27525243                   /lib/x86_64-linux-gnu/libpcre.so.3.13.3
7f8f5ed1f000-7f8f5ed20000 rw-p 00072000 fd:00 27525243                   /lib/x86_64-linux-gnu/libpcre.so.3.13.3
7f8f5ed20000-7f8f5eede000 r-xp 00000000 fd:00 27528422                   /lib/x86_64-linux-gnu/libc-2.24.so
7f8f5eede000-7f8f5f0dd000 ---p 001be000 fd:00 27528422                   /lib/x86_64-linux-gnu/libc-2.24.so
7f8f5f0dd000-7f8f5f0e1000 r--p 001bd000 fd:00 27528422                   /lib/x86_64-linux-gnu/libc-2.24.so
7f8f5f0e1000-7f8f5f0e3000 rw-p 001c1000 fd:00 27528422                   /lib/x86_64-linux-gnu/libc-2.24.so
7f8f5f0e3000-7f8f5f0e7000 rw-p 00000000 00:00 0
7f8f5f0e7000-7f8f5f10c000 r-xp 00000000 fd:00 27526017                   /lib/x86_64-linux-gnu/libselinux.so.1
7f8f5f10c000-7f8f5f30b000 ---p 00025000 fd:00 27526017                   /lib/x86_64-linux-gnu/libselinux.so.1
7f8f5f30b000-7f8f5f30c000 r--p 00024000 fd:00 27526017                   /lib/x86_64-linux-gnu/libselinux.so.1
7f8f5f30c000-7f8f5f30d000 rw-p 00025000 fd:00 27526017                   /lib/x86_64-linux-gnu/libselinux.so.1
7f8f5f30d000-7f8f5f30f000 rw-p 00000000 00:00 0
7f8f5f30f000-7f8f5f335000 r-xp 00000000 fd:00 27528418                   /lib/x86_64-linux-gnu/ld-2.24.so
7f8f5f38b000-7f8f5f526000 r--p 00000000 fd:00 17571763                   /usr/lib/locale/locale-archive
7f8f5f526000-7f8f5f528000 rw-p 00000000 00:00 0
7f8f5f530000-7f8f5f534000 rw-p 00000000 00:00 0
7f8f5f534000-7f8f5f535000 r--p 00025000 fd:00 27528418                   /lib/x86_64-linux-gnu/ld-2.24.so
7f8f5f535000-7f8f5f536000 rw-p 00026000 fd:00 27528418                   /lib/x86_64-linux-gnu/ld-2.24.so
7f8f5f536000-7f8f5f537000 rw-p 00000000 00:00 0
7ffee2f48000-7ffee2f69000 rw-p 00000000 00:00 0                          [stack]
7ffee2f9a000-7ffee2f9c000 r--p 00000000 00:00 0                          [vvar]
7ffee2f9c000-7ffee2f9e000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
E: Sub-process /usr/bin/dpkg exited unexpectedly

Trying to fix it doesn't bring any good results either

We've tried multiple fixes to this including: dpkg –configure -a, apt-get install -f, apt-get install –reinstall unifi=5.5.19-9547

root@Evo:~# apt-get install -f
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
root@Evo:~# dpkg --configure -a
root@Evo:~# apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  unifi
The following packages will be upgraded:
  unifi
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/159 MB of archives.
After this operation, 32.8 kB disk space will be freed.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 112164 files and directories currently installed.)
Preparing to unpack .../unifi_5.5.20-9565_all.deb ...
Previous setting (UniFi 5.5.19) is found.
dpkg: error processing archive /var/cache/apt/archives/unifi_5.5.20-9565_all.deb (--unpack):
 subprocess new pre-installation script returned error exit status 2
abort-upgrade: please reinstall previous version

sudo apt-get install --reinstall unifi=5.5.19-9547

We've even tried multiple other things, including removing UniFi which also failed because Ubuntu was claiming the package is inconsistent, very bad state.

Solution

It seems the cause of the problems was our answer to question about backup. We've answered truthfully NO, that we didn't make a backup (since it was a test environment it wasn't really necessary at this time – not that we would suggest doing this on production).

After this installation would throw errors that we've already described above. Fortunately there's an easy fix to this. Just answer YES when asked that you made a backup and everything will fix by itself. It seems the package doesn't come with proper error handling for situation where one would answer NO to backup. From our perspective if there is question about backup either: offer to make a backup during installation or shutdown installation cleanly (with still working UniFi) informing the package upgrade won't be able to continue without proper backup being made before.

Related Posts

Leave a comment

You must be logged in to post a comment.