Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inotify is leaking a file descriptor #3

Closed
nathany opened this issue Jun 28, 2014 · 3 comments
Closed

inotify is leaking a file descriptor #3

nathany opened this issue Jun 28, 2014 · 3 comments

Comments

@nathany
Copy link
Contributor

nathany commented Jun 28, 2014

Reported by @alberts at https://codereview.appspot.com/8202043/#msg6

I noticed that TestFsnotifyDeleteWatchedDir is leaking a file descriptor:

strace -f -q -e inotify_init,open,close ./fsnotify.test
-test.cpu=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
-test.v -test.run=TestFsnotifyDeleteWatchedDir

SIGABRT shows that all the readEvents goroutines (which are in charge of closing
the inotify fd) are still stuck in their read syscall.
This seems like a problem with the current design of Watcher. readEvents is
blocked and can't see the closed done channel.

See #5 regarding blocking behaviour.

@nathany
Copy link
Contributor Author

nathany commented Jun 28, 2014

@matthias-stone reproduced the issue:

So, looking at this in GDB the following squirrelly behaviour occurs: breaking and continuing the code
clears the leaked file descriptors.

Executed with

gdb --args ./fsnotify.test -test.cpu=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
-test.v -test.run=TestFsnotifyDeleteWatchedDir

Sample of leaked file descriptor - note the anon_inode:inotify

total 0
lrwx------ 1 matthias users 64 Jun 21 20:17 0 -> /dev/pts/40
lrwx------ 1 matthias users 64 Jun 21 20:17 1 -> /dev/pts/40
lr-x------ 1 matthias users 64 Jun 21 20:17 10 -> anon_inode:inotify
lr-x------ 1 matthias users 64 Jun 21 20:17 11 -> anon_inode:inotify
lr-x------ 1 matthias users 64 Jun 21 20:17 12 -> anon_inode:inotify
lr-x------ 1 matthias users 64 Jun 21 20:17 13 -> anon_inode:inotify
lr-x------ 1 matthias users 64 Jun 21 20:17 14 -> anon_inode:inotify
lr-x------ 1 matthias users 64 Jun 21 20:17 15 -> anon_inode:inotify
lr-x------ 1 matthias users 64 Jun 21 20:19 16 -> anon_inode:inotify
lr-x------ 1 matthias users 64 Jun 21 20:19 18 -> anon_inode:inotify
lrwx------ 1 matthias users 64 Jun 21 20:17 2 -> /dev/pts/40
lrwx------ 1 matthias users 64 Jun 21 20:17 3 -> socket:[289525025]
lrwx------ 1 matthias users 64 Jun 21 20:17 4 -> socket:[289525026]
lr-x------ 1 matthias users 64 Jun 21 20:17 5 -> pipe:[289525027]
l-wx------ 1 matthias users 64 Jun 21 20:17 6 -> pipe:[289525027]
lr-x------ 1 matthias users 64 Jun 21 20:17 7 -> anon_inode:inotify
lr-x------ 1 matthias users 64 Jun 21 20:17 8 -> anon_inode:inotify
lr-x------ 1 matthias users 64 Jun 21 20:17 9 -> anon_inode:inotify

@nathany nathany modified the milestone: v2 Internal Cleanup Sep 24, 2014
PieterD referenced this issue in PieterD/fsnotify Feb 6, 2015
…routine (fixes go-fsnotify/fsnotify#3) (fixes go-fsnotify/fsnotify#5)
@nathany
Copy link
Contributor Author

nathany commented Feb 7, 2015

I don't know what I'm doing 👎

strace: Can't stat './fsnotify.test': No such file or directory

GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
./fsnotify.test: No such file or directory.

@PieterD
Copy link
Contributor

PieterD commented Feb 7, 2015

go test -c

@PieterD PieterD closed this as completed in 82a2c3d Feb 7, 2015
djoyner pushed a commit to SpirentOrion/fsnotify that referenced this issue Jan 6, 2021
windows: expose support for recursive directory watches
nathany added a commit that referenced this issue Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants