-
Notifications
You must be signed in to change notification settings - Fork 113
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
Conversation
This prevents an endless loop in the face of recursive symbolic links. Signed-off-by: Max Brunsfeld <[email protected]>
Signed-off-by: Max Brunsfeld <[email protected]>
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "nsfw", | |||
"version": "1.0.16", | |||
"name": "@atom/nsfw", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
Looks like this PR fixes #40 |
bb28461
to
b77e49a
Compare
Looks like a lot of tests are failing, any reason why? @nathansobo |
() => {}, | ||
{ debounceMS: DEBOUNCE, errorCallback() {} } | ||
).then((watch) => { | ||
return watch.start(); |
There was a problem hiding this comment.
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.
@nathansobo Any chance you will get to this? |
@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. |
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 viastat
calls. We've had to add a couple morestat
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.