-
Notifications
You must be signed in to change notification settings - Fork 193
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
problem tracking child after libc::fork
#80
Comments
This is expected and is not a bug. Commenting out this line will probably make it work. |
Ok. Thanks. Perhaps it should be noted somewhere? |
Well, ideally it'd probably be the best to just have an env var to configure this behavior. You don't want it to follow fork by default since that would in a lot of cases generate a lot of garbage files when the application you're profiling temporarily calls into subcommand, but I suppose in some cases you'd want to enable it. |
I can make a pr to add an env var. What is the format of existing env vars? |
https://github.com/koute/bytehound/blob/master/preload/src/opt.rs#L121 |
hrm. Disabling that line did not work. |
Okay, wait, by "child after |
yeah. I mean What would I need to do to get it working for that? |
The whole internal state would have to be reset and essentially reinitialized: the queues and caches would have to be cleared, the global locks all forcibly recreated to make sure they're unlocked, the processing thread would have to be spawned again, a new output file would have to be opened, the shadow stack for fast unwinding would have to be flushed, etc. In theory it should be possible, but it's probably going to be quite a bit of work. |
Can you think of a quick workaround? If not, I guess I could look into doing this work... |
Can you give me a little guidance on exactly what I need to do in order to support this scenario? Happy to make a PR, but I don't have time to review all the code... |
There's no workaround. Unfortunately I don't really have the time to give a more detailed guidance, but if you want to try your hands at this feel free to do so. This is, however, a very tricky thing to get right. Here's what I'd do:
|
Ok. Regarding 3: what about hooking fork and ensuring that the state is all in a 'good state' (i.e. nothing is being modified etc.) while we do the actual fork? Also: might it not be an idea to refactor such that there is only a single |
That's not possible unless we'd have a single global lock, but that would slow down the profiling to a crawl so it's not a realistic solution.
That's also not entirely possible. Nevertheless, it wouldn't really change much, because you'd still have to reinitialize everything in an appropriate matter, regardless of whether it's a single static variable or two. |
Ok. I'll take a look at this in the next couple of days. |
It seems that there are issues following
libc::fork
s, no output file is created for the child process.The text was updated successfully, but these errors were encountered: