Skip to content

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

Closed
nathansobo wants to merge 2 commits intoAxosoft:masterfrom
atom:fix-symlink-loops-on-linux
Closed

Fix infinite loop setting up the inotify tree with recursive symbolic links on Linux#41
nathansobo wants to merge 2 commits intoAxosoft:masterfrom
atom:fix-symlink-loops-on-linux

Conversation

@nathansobo
Copy link
Copy Markdown
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 <maxbrunsfeld@gmail.com>
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Comment thread package.json Outdated
{
"name": "nsfw",
"version": "1.0.16",
"name": "@atom/nsfw",
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Tyriar commented Oct 27, 2017

Looks like this PR fixes #40

@implausible
Copy link
Copy Markdown
Contributor

implausible commented Nov 1, 2017

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

Comment thread js/spec/index-spec.js
() => {},
{ debounceMS: DEBOUNCE, errorCallback() {} }
).then((watch) => {
return watch.start();
Copy link
Copy Markdown
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
Copy Markdown
Contributor

@nathansobo Any chance you will get to this?

@nathansobo
Copy link
Copy Markdown
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