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
scm/git: prevent exec bomb with 'env :userpaths' #46
Conversation
Minor technical nitpick: it's not a fork bomb, because it's exec-ing without forking. That's not just a pedantic terminology niggle: it means you can't see the recursion in I'll test this locally once I'm able to set up a local reproduction of the hang, but I probably can't give it a full thumbs-up even if it seems to work: I don't understand why this self-recursion is happening, and I don't really understand why this change would fix it. More importantly, I found that just adding a debugging call to the
So I don't really know what's going on here. |
True; pardon my use of incorrect terminology. Should I fix my commit subject/message?
I tried to explain the scenario in my top comment. It's basically
My guess would be that you tried running this with the sandbox enabled, so that the write to the log file would have killed the wrapper process due to a sandbox violation. (But could be something else; it's really just the first thing that comes to my mind.) Here are step-by-step instructions to reproduce the issue locally before applying my fix:
|
Using `git` from `Formula#install` can cause an exec bomb if used in a formula with `env :userpaths` because that causes both `Library/ENV/4.3` and `Library/ENV/scm` to be in PATH, both of which contain a `git` binary that is the same SCM wrapper. Those will mutually exec each other indefinitely as they fail to detect that they are the same wrapper. Extend the exec-bomb protection to check the paths after all symbolic links have been expanded to prevent this situation. Fixes Homebrew#43. Fixes Homebrew/homebrew-core#133.
5946f26
to
e6919e6
Compare
TL;DR: 👍 Details:
Nah, it's close enough, and that's probably what people will search for anyway. Just wanted to get that in the history to help people who are trying to understand this or debug similar problems.
Ah. I understand now.
Okay, put these two together and I'm 90% convinced. I am running under the sandbox, and was logging to Though when I ran
Probably enough Probably just user error; I'll fiddle with it some more and see if I can figure out what I'm messing up, but this is consistent with your analysis. TestingI tested your PR locally with I think this is the right fix. 👍 |
Also fixes Homebrew/homebrew-core#143 |
Confirmed this works under Jenkins/test-bot with #46. |
Nice work here, chaps. |
Have you written new tests for your changes?brew tests
with your changes locally?Using
git
fromFormula#install
can causea forkan exec bomb if used in a formula withenv :userpaths
because that causes bothLibrary/ENV/4.3
andLibrary/ENV/scm
to be in PATH, both of which contain agit
binary that is the same SCM wrapper. Those will mutuallyforkexec each other indefinitely as they fail to detect that they are the same wrapper.Extend the
fork-bombexec-bomb protection to check the paths after all symbolic links have been expanded to prevent this situation. (This incurs a small performance penalty because we need to rely onPathname
for Ruby 1.8.7 compatibility, but this wrapper isn't performance critical at all.)Note: This must have happened in the past occasionally. Commit 8ca79a6 just made it much more likely to happen due to a subtle change. (And
boost
happens to be a formula that triggers this behavior.)Fixes #43.
Fixes Homebrew/homebrew-core#133.