The Gnu Core Utilities

tail -f gives misleading error message when inotify limit is reached

Reported by A. Bram Neijt on 2011-01-10
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
coreutils
Undecided
auto-bug-coreutils
coreutils (Ubuntu)
Low
Unassigned

Bug Description

Binary package hint: coreutils

When tail -f has inotify enabled and hits the max_user_watches limit of inotify, the resulting error message is very misleading.

To reproduce:
1) Make sure you will hit the limit if you try another inotify request
    sudo sh -c 'echo 10 > /proc/sys/fs/inotify/max_user_watches'
2) Create a file:
    touch /tmp/hello
3) Follow it:
    tail -f /tmp/hello

Result:
tail: cannot watch `/tmp/hello': No space left on device

Expected result:
tail: cannot watch '/tmp/hello' because inotify reported: No space left on device

It can be verified by using strace tail -f /tmp/hello:
inotify_add_watch(4, "/tmp/hello", IN_MODIFY|IN_ATTRIB|IN_DELETE_SELF|IN_MOVE_SELF) = -1 ENOSPC (No space left on device)
---
Architecture: amd64
CheckboxSubmission: c61c47905a08381ec5d89e05cd06d034
CheckboxSystem: d00f84de8a555815fa1c4660280da308
DistroRelease: Ubuntu 10.10
InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Beta amd64 (20100901.1)
NonfreeKernelModules: nvidia
Package: coreutils 8.5-1ubuntu3
PackageArchitecture: amd64
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.utf8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.35-24.42-generic 2.6.35.8
Tags: maverick
Uname: Linux 2.6.35-24-generic x86_64
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare

apport information

tags: added: apport-collected
description: updated
C de-Avillez (hggdh2) wrote :

Thank you for opening this bug and helping make Ubuntu better -- and thank you also for the upstream bug reference, it does help.

On the upstream bug Jim states this was ficed on coreutils 8.6; it is possible this (or a newer) version will be available for Natty (current development release; I will check on what Debian currently has, and request a merge if needed.

Marking Triaged/Low.

Changed in coreutils (Ubuntu):
importance: Undecided → Low
status: New → Triaged
Asif (vadud3) wrote :
Download full text (5.2 KiB)

I am having the exact same issue.

strace tail -f file
execve("/usr/bin/tail", ["tail", "-f", "file"], [/* 39 vars */]) = 0
brk(0) = 0xa1a000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0db215e000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=135434, ...}) = 0
mmap(NULL, 135434, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f0db213c000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\360\1\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1638120, ...}) = 0
mmap(NULL, 3749080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f0db1bac000
mprotect(0x7f0db1d36000, 2093056, PROT_NONE) = 0
mmap(0x7f0db1f35000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x7f0db1f35000
mmap(0x7f0db1f3a000, 21720, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f0db1f3a000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0db213b000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0db2139000
arch_prctl(ARCH_SET_FS, 0x7f0db2139720) = 0
mprotect(0x7f0db1f35000, 16384, PROT_READ) = 0
mprotect(0x60c000, 4096, PROT_READ) = 0
mprotect(0x7f0db2160000, 4096, PROT_READ) = 0
munmap(0x7f0db213c000, 135434) = 0
brk(0) = 0xa1a000
brk(0xa3b000) = 0xa3b000
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=6856112, ...}) = 0
mmap(NULL, 6856112, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f0db1522000
close(3) = 0
open("file", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=15, ...}) = 0
lseek(3, 0, SEEK_CUR) = 0
lseek(3, 0, SEEK_END) = 15
lseek(3, 0, SEEK_SET) = 0
read(3, "this is a file\n", 15) = 15
lseek(3, 0, SEEK_SET) = 0
read(3, "this is a file\n", 15) = 15
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0db215d000
write(1, "this is a file\n", 15this is a file
) = 15
fstat(3, {st_mode=S_IFREG|0644, st_size=15, ...}) = 0
fstatfs(3, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=178230698, f_bfree=96244884, f_bavail=87191291, f_files=45268992, f_ffree=44592588, f_fsid={-449494421, -1492475350}, f_namelen=255, f_frsize=4096}) = 0
inotify_init() = 4
inotify_add_watch(4, "file", IN_MODIFY|IN_ATTRIB|IN_DELETE_SELF|IN_MOVE_SELF) = -1 ENOSPC (No space left on device)
open("/usr/share/locale/locale.alias", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
mmap(NULL, 4096,...

Read more...

Christian Mertes (cmertes) wrote :

Fixed in coreutils 8.6 as per upstream bug report.

A. Bram Neijt (bneijt) wrote :

No problem in core-utils 8.13:
$ sudo sh -c 'echo 10 > /proc/sys/fs/inotify/max_user_watches'
$ touch /tmp/hello
$ tail -f /tmp/hello
tail: inotify resources exhausted
tail: inotify cannot be used, reverting to polling

Changed in coreutils (Ubuntu):
status: Triaged → Fix Released
Changed in coreutils:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

  • auto-bug-coreutils Edit

Bug watches keep track of this bug in other bug trackers.