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

Fix infinite loop setting up the inotify tree with recursive symbolic links on Linux #41

Closed
wants to merge 2 commits into from

Conversation

nathansobo
Copy link
Contributor

Previously, when constructing the InotifyTree, this library would unconditionally follow all symbolic links, even if they pointed to an ancestor of the current path. This would lead to infinite recursion building out a deeper and deeper tree until the process ran out of memory.

In this PR, we associate the tree with an std::unordered_set of inode numbers. These are already obtained in the common case of walking each directory's children via stat calls. We've had to add a couple more stat calls to get the inode of the root of the tree and of any newly added directories.

Now, when processing a directory's children, we only proceed if the inode number associated with the child has never been seen before.

We've added a basic new test with a simple recursive link where we just ensure the test does not time out. We've also run this under valgrind and haven't noticed any abnormal behavior associated with the newly added code.

Nathan Sobo added 2 commits October 27, 2017 16:48
This prevents an endless loop in the face of recursive symbolic links.

Signed-off-by: Max Brunsfeld <[email protected]>
package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "nsfw",
"version": "1.0.16",
"name": "@atom/nsfw",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this was unintentional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that shouldn't be in this PR. Thanks!

@Tyriar
Copy link
Contributor

Tyriar commented Oct 27, 2017

Looks like this PR fixes #40

@implausible
Copy link
Contributor

implausible commented Nov 1, 2017

Looks like a lot of tests are failing, any reason why? @nathansobo

() => {},
{ debounceMS: DEBOUNCE, errorCallback() {} }
).then((watch) => {
return watch.start();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to stop this watcher or the tests are never going to finish.

@implausible
Copy link
Contributor

@nathansobo Any chance you will get to this?

@nathansobo
Copy link
Contributor Author

@implausible Probably not. I opened the PR as a courtesy but we plan to transition away from this library this year so it's hard to justify spending more time on it. I'm sorry. I'll go ahead and close.

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

Successfully merging this pull request may close these issues.

3 participants