Don't understand german? Read or subscribe to my english-only feed.

Error handling: ENOSPC

Hopefully fuzz testing is well known nowadays, right? But did you check how smart your software can handle ENOSPC – the ‘No space left on device’ error?

I like stress testing software (to be honest: no, not really). Yesterday I debugged a problem regarding zsh history writing on ENOSPC. Usually I use the grml Linux live-cd for stress testing (often running inside Qemu, Virtbox, VMware,…) like in:

dd if=/dev/zero of=/tmp/home.lo count=1000
losetup /dev/loop1 /tmp/home.lo
mkfs.ext3 /dev/loop1
mount /dev/loop1 /home
mkdir /home/grml
chown grml: /home/grml

Now after restarting the shell session of user grml I can play with ‘No space left on device’ situations. (Notice: I adjust the count=… according to what type of application I want to test.)

Too many applications don’t really cope with the ENOSPC situation. Firefox for example is very funny, depending on the situation it either just segfaults when trying to start up, or decides to not start up at all and just exits with ‘1’. See the relevant strace output:

mkdir("/home", 0700)                    = -1 EEXIST (File exists)
access("/home", F_OK)                   = 0
mkdir("/home/grml", 0700)               = -1 EEXIST (File exists)
access("/home/grml", F_OK)              = 0
mkdir("/home/grml/.mozilla", 0700)      = -1 ENOSPC (No space left on device)
access("/home/grml/.mozilla", F_OK)     = -1 ENOENT (No such file or directory)
exit_group(1)                           = ?

Opera also just exits when already running and receiving an ENOSPC – I encountered data loss (for example the transfer history got lost) more than once. Very "funny" to see how applications like dillo, joe, wireshark,… behave in the ENOSPC situation. Not.

Oh, your application handles ENOSPC just fine? Then continue testing with read-only filesystem, using NFS, removing files randomly,…

6 Responses to “Error handling: ENOSPC”

  1. haypo Says:

    You may also try /dev/full device :-)

  2. Michael Scherer Says:

    A friend just told me of /dec/full ( man full ), it is also used for this kind of test.

  3. Michael Scherer Says:

    ok he was faster than me to comment on your blog entry :)

  4. mika Says:

    @haypo + Michael:

    Cool, thanks for the hint! :) The loopback way of life I chose has the advantage that you can fiddle with “we have some free space left” and “now we are running out of disk….” too, but thanks for the usefull hint!

    regards,
    -mika-

  5. Martin Bergner Says:

    Nice that you talk about this. My university gives me 30 MB of space which is full rather quickly. Me, as a tutor, have seen many people being unable to login because of this situation. It would be a lot easier if applications just told you: “You don’t have space left, things might not work as expected but I won’t crash on you, just free some space”. Of course, they should also follow this line then.

  6. nona Says:

    This is a pet peeve of mine as a user, but as a developer I understand it takes quite a lot of discipline to create apps that are robust in the face of out-of-diskspace or even out-of-memory errors.

    My favourite browser epiphany used to have this horrid bug where if you ran out of diskspace while downloading, all download attempts afterwards would fail too – even if you freed space and restarted the browser. Glad it’s fixed now.