-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Modify environment variables from native extensions (profilers etc) #12310
Comments
Inject to what? Do you think the right solution is to instrument the user code to call
But it should be an option. How to control its behavior in this case? |
@k15tfu I have listed the options that work today. This issue can be used to discuss a new profiler API to do this. |
@k15tfu - What code is being used to launch the child processes? Is it code your profiler controls or it is outside of your control? The typical way profilers avoid triggering for child processes or any other unintended process is that they test which process they reside within early in initialization. If it isn't a process that you want to load the profiler then you can safely return from DllCreateObject or any of the other early initialization APIs without doing any work. The profiler load will fail and the runtime will execute as normal with no profiling activity. |
Hi! As I already said we want to control environment variables from profiler. On Windows all of these cases work:
Moreover, we have some extra logic that depends on the position of the current process in the app's childs hierarchy, and its implementation is based on the inheritance of environment variables.
no, it's outside of our control.
It's okay if we don't want to profile childs always (no. 2), but how to support cases no.1 & no.3 ? |
Hi @noahfalk, I follow this discussion for a long time and I have the idea. What do you think about extend the |
@davmason Can you please return the |
@davmason Yep, this API looks good to me. Is there a chance to get it implemented in 3.1? Unfortunately these workarounds don't work in all scenarios: Make profiler for child processes to be no-op doesn't suite for cases no.1 & no.3. The other option about injecting the call will not work after attach. |
@k15tfu no work has happened on this yet. For it to be considered for 3.1 the following steps would have to occur:
All of this would have to happen in a relatively short timeframe to make 3.1, and it would not be guaranteed to meet the 3.1 bar since there is a workaround and this is "feature work" (as opposed to bug fixes). There is also a strong chance that the work would go on too far to make the 3.1 cut off. None of this work is currently scheduled so the likelihood that it will make 3.1 as it stands is very low (effectively it won't make 3.1). If you feel strongly enough to help out, we are always happy to accept pull requests from the community. |
@davmason @noahfalk @jkotas I added only one new method in corprof.idl: dotnet/coreclr#27157 . Anything else? |
@k15tfu If we are adding profiler APIs to deal with environment variables, we should address the entire scenario. What if a profiler wants to retrieve the value environment variables or remove an environment variable? Removal could be done with the same |
@davmason Sure, I'll add it too. Do we need something to get all of them (like |
@k15tfu I don't think we necessarily need it, but I also wouldn't be opposed to having it if it were relatively easy to implement. I suspect it's more trouble than it's worth since you'd have to follow the same pattern as the other profiler APIs that allow you to enumerate things (like I think just Get/Set methods for one variable is all that's necessary. |
Well, glad to close this issue. Thanks @davmason for your help. |
@jkotas Hi again! I have a similar problem: The profiler modifies the environment variable at startup to control the way the child processes' profilers work. For example, it can be used to make profiling of child processes optional. Unfortunately coreclr does EnvironInitialize() before profiler startup, so I cannot unset environment variables. Can you suggest how to deal with that?
I see a few options:
Originally posted by @k15tfu in https://github.com/dotnet/coreclr/issues/635#issuecomment-473985581
The text was updated successfully, but these errors were encountered: