Skip to content
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

Invoke startup hook from ApplyStartupHook diagnostic command #87490

Merged
merged 4 commits into from
Jun 17, 2023

Conversation

jander-msft
Copy link
Member

Update the new ApplyStartupHook diagnostic command to execute the startup hook if managed execution is already running. Add a test that starts an application, waits for managed code to start executing, applies the startup hook, and has the application validate that the startup hook was actually invoked.

cc @dotnet/dotnet-monitor

closes #83756

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Jun 13, 2023
@ghost
Copy link

ghost commented Jun 13, 2023

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

Update the new ApplyStartupHook diagnostic command to execute the startup hook if managed execution is already running. Add a test that starts an application, waits for managed code to start executing, applies the startup hook, and has the application validate that the startup hook was actually invoked.

cc @dotnet/dotnet-monitor

closes #83756

Author: jander-msft
Assignees: -
Labels:

area-Diagnostics-coreclr

Milestone: -

@tommcdon
Copy link
Member

@davmason @hoyosjs

GCX_COOP();

// Load and call startup hook since managed execution is already running.
MethodDescCallSite callStartupHook(METHOD__STARTUP_HOOK_PROVIDER__CALL_STARTUP_HOOK);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that these can get loaded mid process - do we correctly document synchronization guarantees (none pretty much other than loading happens once) and expectations for injected code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There aren't any guarantees around synchronization. Also, you could invoke this multiple times with the same startup hook assembly path, while the assembly should only be loaded once, its StartupHook.Initialize method would be called each time; it would be the responsibility of the startup hook implementation to guard against multiple execution, if it is impacted at all by it.

@jander-msft
Copy link
Member Author

Test failures are due to the StartupHookTests.InvalidSimpleAssemblyName test method testing an implementation detail that if any of the specified assemblies are invalid then nothing is executed whereas my change allows execution of each startup hook in sequence up until the first failure. It'll rewrite my update to maintain the prior implementation behavior.

@jander-msft
Copy link
Member Author

If there is no other feedback, could I get this merged?

The two test jogs that are timing out are from Alma Linux Helix jobs, which were just removed in the main branch ~20 minutes ago: 4ae1668

@davmason davmason merged commit 61ce817 into dotnet:main Jun 17, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Diagnostics-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Diagnostic IPC command to dynamically add startup hook at diagnostic startup suspension
4 participants