Commit 8ff3668
authored
[Startup] Bump PerfMap ahead of DiagnosticServer (#123226)
Fixes #122472
From some inspection, it looks like `PerfMap::Initialize` does not
depend on the methods right above it.
```
#ifdef FEATURE_PERFTRACING
DiagnosticServerAdapter::Initialize();
DiagnosticServerAdapter::PauseForDiagnosticsMonitor();
#endif // FEATURE_PERFTRACING
#ifdef FEATURE_GDBJIT
// Initialize gdbjit
NotifyGdb::Initialize();
#endif // FEATURE_GDBJIT
#ifdef FEATURE_EVENT_TRACE
// Initialize event tracing early so we can trace CLR startup time events.
InitializeEventTracing();
// Fire the EE startup ETW event
ETWFireEvent(EEStartupStart_V1);
#endif // FEATURE_EVENT_TRACE
InitGSCookie();
#ifdef LOGGING
InitializeLogging()
#endif
```
`PerfMap::Initialize` depends on `SString::Startup()` which occurs
earlier in startup and some PAL/OS services.
Instead of adding more logic to handle a racing DiagnosticServer IPC
[`EnablePerfMap`
command](https://github.com/dotnet/diagnostics/blob/main/documentation/design-docs/ipc-protocol.md#enableperfmap)
and `PerfMap::Initialize` (e.g. lazy-init/queued commands), bump the
PerfMap initialization ahead of the DiagnosticServer initialization. The
DiagnosticServer also doesn't depend on PerfMap being initialized
afterwards, and PerfMap's `CrstStatic` and `PerfMap::Enable(type,
sendExisting)` suggests that the IPC enable perfmap command should occur
after `PerfMap::Initialize`.
This way, DiagnosticServer is still early in startup, and its
`PerfMap::Enable` will not crash the runtime.
As for the IPC command to set environment variables, it is unlikely that
it was used to `DOTNET_PerfMapEnabled` because that would either not
have applied early enough or have crashed the runtime like in the issue.
Instead, the `EnablePerfMap`/`DisablePerfMap` commands should be used to
toggle PerfMap status.1 parent d37862b commit 8ff3668
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
706 | 706 | | |
707 | 707 | | |
708 | 708 | | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
709 | 713 | | |
710 | 714 | | |
711 | 715 | | |
| |||
731 | 735 | | |
732 | 736 | | |
733 | 737 | | |
734 | | - | |
735 | 738 | | |
736 | 739 | | |
737 | 740 | | |
| |||
0 commit comments