You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: Documentation/Profiling/Profiler Loading.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ If any of these environment variable are present, we skip the registry look up a
16
16
17
17
A couple things to note about this:
18
18
- If you specify `CORECLR_PROFILER_PATH`_and_ register your profiler, then `CORECLR_PROFILER_PATH` always wins. Even if `CORECLR_PROFILER_PATH` points to an invalid path, we will still use `CORECLR_PROFILER_PATH`, and just fail to load your profiler.
19
-
-`CORECLR_R_PROFILER` is _always required_. If you specify `CORECLR_PROFILER_PATH`, we skip the registry look up. We still need to know your profiler's CLSID, so we can pass it to your class factory's CreateInstance call.
19
+
-`CORECLR_PROFILER` is _always required_. If you specify `CORECLR_PROFILER_PATH`, we skip the registry look up. We still need to know your profiler's CLSID, so we can pass it to your class factory's CreateInstance call.
#### Normally unamiguous APIs related to affected APIs
70
81
```C#
71
82
namespaceSystem
72
83
{
@@ -78,9 +89,9 @@ namespace System
78
89
}
79
90
}
80
91
```
81
-
In this case, `assemblyResolver` functionally specifies the explicit mechanism to load. This indicates the current assembly's `AssmblyLoadContext` is not being used. If the `assemblyResolver` is only serving as a first or last chance resolver, then these would also be in the set of affected APIs.
82
-
#### Should be affected APIs
83
-
Issue https://github.com/dotnet/coreclr/issues/22213, discusses scenarios in which various flavors of the API `GetType()` is not functioning correctly. As part of the analysis and fix of that issue, the set of affected APIs may increase.
92
+
In this case, `assemblyResolver` functionally specifies the explicit mechanism to load.
93
+
94
+
If the `assemblyResolver` is `null`, assembly loads for these occur when `typeName` includes a assembly-qualified type reference.
84
95
### Root cause analysis
85
96
In .NET Framework, plugin isolation was provided by creating multiple `AppDomain` instances. .NET Core dropped support for multiple `AppDomain` instances. Instead we introduced `AssemblyLoadContext`.
My natural inclination would be to replace most native calls taking a `StackCrawlMark` with callS taking the `CurrentContextualReflectionContext`. When `CurrentContextualReflectionContext` is `null`, resolve the `StackCrawlMark` first, passing the result as the inferred context.
234
+
The affected runtime native calls correspond to the runtime's mechanism to load an assembly, and to get a type. Each affected native call is passed a managed reference to the CurrentContextualReflectionContext. This prevents GC holes, while running the native code. The `CurrentContextualReflectionContext` acts as the mechanism for resolving assembly names to assemblies.
227
235
228
-
However this may require mutiple native/managed transitions. Performance considerations may require Native calls which currently take a `StackCrawlMark` will need to be modified to also take `CurrentContextualReflectionContext`.
236
+
### Unloadability
229
237
230
-
### Hypothetical Advanced/Problematic use cases
238
+
`CurrentContextualReflectionContext` will hold an `AssemblyLoadContext` reference. This will prevent the context from being unloaded while it could be used. As an `AsyncLocal<AssemblyLoadContext>`, the setting will propagate to child threads and asynchronous tasks.
239
+
After a thread or asynchronous task completes, the `AsyncLocal<AssemblyLoadContext>` will eventually be cleared, this will unblock the `AssemblyLoadContext` unload. The timing of this unload depends on the ThreadPool implementation.
231
240
232
-
One could imagine complicated scenarios in which we need to handle ALCs on event callback boundaries. These are expected to be rare. The following are representative patterns that demonstrate the possibility to be support these more complicated usages.
241
+
### ContextualReflectionScope
233
242
234
-
#### An incoming event handler into an AssemblyLoadContext
235
243
```C#
236
-
voidOnEvent()
244
+
/// <summary>Opaque disposable struct used to restore CurrentContextualReflectionContext</summary>
245
+
/// <remarks>
246
+
/// This is an implmentation detail of the AssemblyLoadContext.EnterContextualReflection APIs.
`_initialized` is included to prevent useful default construction. It prevents the `default(ContextualReflectionScope).Dispose()` case.
279
+
280
+
`_predecessor` represents the previous value of `CurrentContextualReflectionContext`. It is used by `Dispose()` to restore the previous state.
281
+
282
+
`_activated` is included as a potential aid to debugging. It serves no other useful purpose.
283
+
284
+
This struct is implemented as a readonly struct. No state is modified after construction. This means `Dispose()` can be called multiple times. This means `using` blocks will always restore the previous `CurrentContextualReflectionContext` as exiting.
285
+
286
+
### Unusual usage patterns
287
+
288
+
There are some unusual usage patterns which are not recommended, but not prohibited. They all have reasonable behaviors.
289
+
290
+
* Clear but never restore the CurrentContextualReflectionContext
Copy file name to clipboardExpand all lines: Documentation/project-docs/clr-configuration-knobs.csx
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -350,13 +350,13 @@ public static class ConfigKnobsDoc
350
350
"## Environment/Registry Configuration Knobs\n";
351
351
352
352
publicstaticstringClrConfigSectionInfo=
353
-
"This table was machine-generated using `clr-configuration-knobs.csx` script from repository commit [GIT_SHORT_HASH](https://github.com/dotnet/coreclr/commit/GIT_LONG_HASH) on DATE_CREATED. It might be out of date. To generate latest documentation run `{dotnet} csi clr-configuration-knobs.csx` from this file directory.\n";
353
+
"This table was machine-generated using `clr-configuration-knobs.csx` script from repository commit [GIT_SHORT_HASH](https://github.com/dotnet/coreclr/commit/GIT_LONG_HASH) on DATE_CREATED. It might be out of date. To generate latest documentation run `dotnet-script clr-configuration-knobs.csx` from this file directory.\n";
354
354
355
355
publicstaticstringClrConfigSectionUsage=
356
356
"When using these configurations from environment variables, the variables need to have the `COMPlus_` prefix in their names. e.g. To set DumpJittedMethods to 1, add the environment variable `COMPlus_DumpJittedMethods=1`.\n\nSee also [Setting configuration variables](../building/viewing-jit-dumps.md#setting-configuration-variables) for more information.\n";
357
357
358
358
publicstaticstringClrConfigTableHeader=
359
-
"\nName | Description | Type | Class | Default Value | Flags\n"+
359
+
"\nName | Description | Type | Class | Default Value | Flags\n"+
0 commit comments