#756619 apt-get update: SIGBUS when run out of disk space

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Jakub Wilk
Date:
2014-08-01 18:42:15 UTC
Severity:
normal
#756619#3
Date:
2014-07-31 11:52:56 UTC
From:
To:
"apt-get update" dies with SIGBUS when there's very little free space on
disk:

# rm -f /var/cache/apt/*.*

# df -h /var
Filesystem                                              Size  Used Avail Use% Mounted on
/dev/disk/by-uuid/0fbbe877-619a-4769-9583-1f6ca4084685  2.0G  1.9G   25M  99% /

# apt-get update
Hit http://ftp.debian.org unstable InRelease
Hit http://ftp.debian.org unstable/main amd64 Packages/DiffIndex
Bus error (core dumped). 60%


GDB backtrace:

#0  0x00007ffff7ace7be in pkgCacheGenerator::NewDepends (this=0x7fffffffe100, Pkg=..., Ver=..., Version=16019563, Op=@0x7fffffffced4: 2, Type=@0x7fffffffcfa0: 1,
    OldDepLast=@0x7fffffffd5c8: 0x0) at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/pkgcachegen.cc:939
#1  0x00007ffff7ace6cf in pkgCacheGenerator::NewDepends (this=0x7fffffffe100, Pkg=..., Ver=..., Version=..., Op=@0x7fffffffced4: 2, Type=@0x7fffffffcfa0: 1,
    OldDepLast=@0x7fffffffd5c8: 0x0) at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/pkgcachegen.cc:921
#2  0x00007ffff7acec5f in pkgCacheGenerator::ListParser::NewDepends (this=0x7fffffffd5a0, Ver=..., PackageName=..., Arch=..., Version=..., Op=2, Type=1)
    at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/pkgcachegen.cc:1003
#3  0x00007ffff7b37655 in debListParser::ParseDepends (this=0x7fffffffd5a0, Ver=..., Tag=0x7ffff7b83793 "Depends", Type=1)
    at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/deb/deblistparser.cc:771
#4  0x00007ffff7b34c30 in debListParser::NewVersion (this=0x7fffffffd5a0, Ver=...) at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/deb/deblistparser.cc:166
#5  0x00007ffff7acbf2a in pkgCacheGenerator::MergeListVersion (this=0x7fffffffe100, List=..., Pkg=..., Version=..., OutVer=@0x7fffffffd2d8: 0x0)
    at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/pkgcachegen.cc:410
#6  0x00007ffff7acae50 in pkgCacheGenerator::MergeList (this=0x7fffffffe100, List=..., OutVer=0x0) at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/pkgcachegen.cc:245
#7  0x00007ffff7b2d2dc in debPackagesIndex::Merge (this=0x645b60, Gen=..., Prog=0x7fffffffe320) at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/deb/debindexfile.cc:338
#8  0x00007ffff7ad01d3 in BuildCache (Gen=..., Progress=0x7fffffffe320, CurrentSize=@0x7fffffffe080: 34150740, TotalSize=34351968, Start=..., End=...)
    at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/pkgcachegen.cc:1302
#9  0x00007ffff7ad1546 in pkgCacheGenerator::MakeStatusCache (List=..., Progress=0x7fffffffe320, OutMap=0x7fffffffe480, AllowMem=false)
    at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/pkgcachegen.cc:1494
#10 0x00007ffff7a9ba1c in pkgCacheFile::BuildCaches (this=0x7fffffffe470, Progress=0x7fffffffe320, WithLock=true) at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/cachefile.cc:90
#11 0x00007ffff779c4b1 in CacheFile::BuildCaches (this=0x7fffffffe470, WithLock=true) at ../build/include/apt-private/private-cachefile.h:27
#12 0x00007ffff779c119 in DoUpdate (CmdL=...) at /build/apt-S02Gn6/apt-1.0.6/apt-private/private-update.cc:74
#13 0x00007ffff7b7743e in CommandLine::DispatchArg (this=0x7fffffffea60, Map=0x7fffffffea80, NoMatch=true) at /build/apt-S02Gn6/apt-1.0.6/apt-pkg/contrib/cmndline.cc:380
#14 0x00000000004221c2 in main (argc=2, argv=0x7fffffffecb8) at /build/apt-S02Gn6/apt-1.0.6/cmdline/apt-get.cc:1738

#756619#8
Date:
2014-08-01 17:57:54 UTC
From:
To:
I just wonder how this happens. APT is writing to an mmap. That mmap
has been allocated on the disk already, so it should not fail, unless
the FS lied and has no space anymore, despite having promised it to
APT, or am I wrong?

#756619#13
Date:
2014-08-01 17:57:54 UTC
From:
To:
I just wonder how this happens. APT is writing to an mmap. That mmap
has been allocated on the disk already, so it should not fail, unless
the FS lied and has no space anymore, despite having promised it to
APT, or am I wrong?

#756619#16
Date:
2014-08-01 18:41:50 UTC
From:
To:
* Julian Andres Klode <jak@jak-linux.org>, 2014-08-01, 19:57:

How does apt allocate the space? In the DynamicMMap constructor I see:

      Fd->Seek(WorkSpace - 1);
      char C = 0;
      Fd->Write(&C,sizeof(C));

which would create just a sparse file. Maybe posix_fallocate(3) is
needed instead?

(But I'm not familiar with apt codebase, so maybe I'm looking at the
completely wrong place.)