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

Cycles of symlinks cause infinite loop/recursion #21

Closed
akerbos opened this issue Oct 18, 2012 · 4 comments
Closed

Cycles of symlinks cause infinite loop/recursion #21

akerbos opened this issue Oct 18, 2012 · 4 comments

Comments

@akerbos
Copy link

akerbos commented Oct 18, 2012

When used in combination with guard/listen, cycles of symlinks cause nontermination. I don't quite know whether the reason lies here or in listen.

See also here.

@nex3
Copy link
Collaborator

nex3 commented Dec 1, 2012

Can you reproduce this with rb-inotify alone?

@juhaerk
Copy link
Contributor

juhaerk commented Dec 14, 2016

I think I have run into this with no guard/listen involved. The following code triggers the issue (tested on Ubuntu Trusty, with both rb-inotify 0.9.2 and 0.9.7, on Linux kernel 3.13.0 and ruby 2.0).

#!/usr/bin/ruby2.0
# -*- coding: utf-8 -*-

require 'rb-inotify'

notifier = INotify::Notifier.new

events = [ :dont_follow, :recursive, ]
path   = '/proc/self'

notifier.watch(path, *events) do |event|
  puts "Got event at: #{ event.absolute_name }"
end

The process gets into an apparent infinite loop, going through paths such as /proc/self/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/8/task/28712/fd/9/28713/root/sys/devices/system/memory/memory53/power

I do not think :recursive should behave this way, and especially :dont_follow should prevent that. A link to "/" is enough, it does not have to go through "/proc", but if "/proc" is mounted I think that will happen anyway.

I suppose the RECURSIVE_BLACKLIST in code is meant to guard against this somehow, but it is not effective.

This change appears to fix it: #60

@ioquatix
Copy link
Member

Can you confirm this is fixed?

@ioquatix
Copy link
Member

Running the example provided by @juhaerk seems to work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants