-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[release/10.0] Fix PerfMap crash when Enable IPC command is sent early in startup #124208
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
[release/10.0] Fix PerfMap crash when Enable IPC command is sent early in startup #124208
Conversation
|
Tagging subscribers to this area: @agocke |
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.
Pull request overview
Backports fixes to CoreCLR startup/diagnostics so an early DiagnosticServer IPC EnablePerfMap command (e.g., during PauseForDiagnosticsMonitor) no longer crashes the runtime by invoking PerfMap “send existing” logic before the AppDomain / EEJitManager are initialized.
Changes:
- Move
PerfMap::Initialize()earlier inEEStartupHelper()so PerfMap infrastructure is ready beforeDiagnosticServerAdapter::Initialize()starts listening for IPC. - Add a
PerfMapreadiness flag to gatesendExistingbehavior until startup dependencies are initialized. - Signal readiness (
PerfMap::SignalDependenciesReady()) immediately afterExecutionManager::Init().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/coreclr/vm/perfmap.h |
Adds a new volatile readiness flag and a public signal API to indicate when sendExisting can safely run. |
src/coreclr/vm/perfmap.cpp |
Implements the readiness flag, skips sendExisting enumeration if dependencies aren’t ready, and adds SignalDependenciesReady(). |
src/coreclr/vm/ceemain.cpp |
Reorders PerfMap initialization ahead of DiagnosticServer startup and signals readiness after ExecutionManager::Init(). |
|
/ba-g "Known infrastructure issue" |
|
/ba-g known pkg_resources issue |
Manual backport of #123226 and #124055 to release/10.0
Customer Impact
The DiagnosticServer allows profilers to enable PerfMap early in start-up, even before PerfMap is initialized and dependencies are ready, inducing a crash. Enabling PerfMap this early in start-up was not tested until user_events support was added in .NET 10, where One-Collect's record-trace aggressively enables PerfMaps as soon as it connects to a .NET Process so it can resolve JIT'd code. As .NET user_events + record-trace gains more users, this crash will likely be observed more frequently.
With the changes in the two PRs, the runtime is resilient to early PerfMap::Enable commands received by the DiagnosticServer.
DiagnosticServer initialization will still be early in start-up, PerfMap initialization is just bumped right before it.
Regression
Testing
I validated on a wsl2 instance, pausing the startup logic with DOTNET_DefaultDiagnosticPortSuspend=1 and kicking off a separate app invoking DiagnosticClient.EnablePerfMap. Before the change, it would sigsegv and crash.
After the changes, its resilient and doesn't crash.
Risk
Low. PerfMap initialization doesn't depend on the logic between its former and proposed location. The logic to handle early IPC PerfMap Enable commands makes the problematic logic a no-op until the dependencies are ready.