[Aptitude-devel] Bug#906695: aptitude: apt doesn't call fsync on the file extended_states

Mikulas Patocka mikulas at twibright.com
Sun Aug 19 20:51:48 BST 2018


Package: aptitude
Version: 0.8.7-1
Severity: normal

Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?

apt doesn't call fsync when writing the file extended_states - so that if
the system crashes while doing updates, the file extended_states is
corrupted

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

If you strace aptitude, you can see that it writes the file
extended_states this way. There's no fsync, and therefore there's no
guarantee that the file will be written when renaming it to the permanent
state.

15267 open("/var/lib/apt/extended_states.plCi2E", O_RDWR|O_CREAT|O_EXCL, 0600) = 74
15267 umask(000)                        = 022
15267 umask(022)                        = 000
15267 fchmod(74, 0644)                  = 0
15267 fcntl(74, F_SETFD, FD_CLOEXEC)    = 0
15267 write(74, "Package: libmpc2\n", 17) = 17
15267 write(74, "Architecture: amd64\n", 20) = 20
15267 write(74, "Auto-Installed: 1\n", 18) = 18
15267 write(74, "\n", 1)                = 1
15267 write(74, "Package: automake1.9\n", 21) = 21
15267 write(74, "Architecture: amd64\n", 20) = 20
15267 write(74, "Auto-Installed: 1\n", 18) = 18
15267 write(74, "\n", 1)                = 1
15267 write(74, "Package: automake1.10\n", 22) = 22
15267 write(74, "Architecture: amd64\n", 20) = 20
15267 write(74, "Auto-Installed: 1\n", 18) = 18
15267 write(74, "\n", 1)                = 1
....
15267 close(74)                         = 0
15267 rename("/var/lib/apt/extended_states.plCi2E", "/var/lib/apt/extended_states") = 0
15267 chmod("/var/lib/apt/extended_states", 0644) = 0

   * What was the outcome of this action?

I had my file extended_states corrupted when the system crashed while
doing unattended upgrades.

   * What outcome did you expect instead?

apt should call fsync before closing the file handle


*** End of the template - remove these template lines ***


-- Package-specific info:
Terminal: linux
$DISPLAY not set.
which aptitude: /usr/bin/aptitude

aptitude version information:
aptitude 0.8.7
Compiler: g++ 6.3.0 20170406
Compiled against:
  apt version 5.0.1
  NCurses version 6.0
  libsigc++ version: 2.10.0
  Gtk+ support disabled.
  Qt support disabled.

Current library versions:
  NCurses version: ncurses 6.0.20161126
  cwidget version: 0.5.17
  Apt version: 5.0.1

aptitude linkage:
	linux-vdso.so.1 (0x00007fff917fc000)
	libapt-pkg.so.5.0 => /usr/lib/x86_64-linux-gnu/libapt-pkg.so.5.0 (0x00007f4d8f1f1000)
	libncursesw.so.5 => /lib/x86_64-linux-gnu/libncursesw.so.5 (0x00007f4d8efc1000)
	libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f4d8ed97000)
	libsigc-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libsigc-2.0.so.0 (0x00007f4d8eb90000)
	libcwidget.so.3 => /usr/lib/x86_64-linux-gnu/libcwidget.so.3 (0x00007f4d8e893000)
	libsqlite3.so.0 => /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f4d8e58b000)
	libboost_iostreams.so.1.62.0 => /usr/lib/x86_64-linux-gnu/libboost_iostreams.so.1.62.0 (0x00007f4d8e373000)
	libboost_filesystem.so.1.62.0 => /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.62.0 (0x00007f4d8e15a000)
	libboost_system.so.1.62.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.62.0 (0x00007f4d8df56000)
	libxapian.so.30 => /usr/lib/x86_64-linux-gnu/libxapian.so.30 (0x00007f4d8db42000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4d8d925000)
	libstdc++.so.6 => /usr/local/gcc/lib64/libstdc++.so.6 (0x00007f4d8d585000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4d8d281000)
	libgcc_s.so.1 => /usr/local/gcc/lib64/libgcc_s.so.1 (0x00007f4d8d068000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4d8ccc9000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4d8cac5000)
	libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f4d8c8ae000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f4d8c694000)
	libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f4d8c484000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f4d8c25e000)
	liblz4.so.1 => /usr/lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f4d8c04c000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f4d8be44000)
	libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f4d8bc3f000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f4d8fbba000)

-- System Information:
Debian Release: 9.5
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, arm64, armel, armhf, mips, mips64el, ppc64el, s390x

Kernel: Linux 4.4.128 (SMP w/12 CPU cores; PREEMPT)
Locale: LANG=cs_CZ, LC_CTYPE=cs_CZ (charmap=ISO-8859-2), LANGUAGE=cs_CZ (charmap=ISO-8859-2)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages aptitude depends on:
ii  aptitude-common            0.8.7-1
ii  libapt-pkg5.0              1.4.8
ii  libboost-filesystem1.62.0  1.62.0+dfsg-4
ii  libboost-iostreams1.62.0   1.62.0+dfsg-4
ii  libboost-system1.62.0      1.62.0+dfsg-4
ii  libc6                      2.24-11+deb9u3
ii  libcwidget3v5              0.5.17-4+b1
ii  libgcc1                    1:6.3.0-18+deb9u1
ii  libncursesw5               6.0+20161126-1+deb9u2
ii  libsigc++-2.0-0v5          2.10.0-1
ii  libsqlite3-0               3.16.2-5+deb9u1
ii  libstdc++6                 6.3.0-18+deb9u1
ii  libtinfo5                  6.0+20161126-1+deb9u2
ii  libxapian30                1.4.3-2+deb9u1

Versions of packages aptitude recommends:
pn  libparse-debianchangelog-perl  <none>
ii  sensible-utils                 0.0.9+deb9u1

Versions of packages aptitude suggests:
pn  apt-xapian-index                <none>
pn  aptitude-doc-en | aptitude-doc  <none>
pn  debtags                         <none>
pn  tasksel                         <none>

-- no debconf information



More information about the Aptitude-devel mailing list