Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/pipelines/diagnostics/sos-test-leg.yml
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
# sos-test-leg.yml -- wraps the matrix + job + dep + artifact download +
# standard postBuildSteps pattern used by the SOS-style test legs (cDAC,
# cDAC_fallback, cDAC_verify, DAC) that run on windows_x64. Each of those legs
# cDAC_verify, DAC) that run on windows_x64. Each of those legs
# only differs in its `name` and `dacMode` value.
#
# AzDO tasks workaround:
Expand Down
13 changes: 4 additions & 9 deletions eng/pipelines/runtime-diagnostics.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,8 +3,8 @@
# Pipeline overview:
#
# SOSTests windows_x64 Release. One shared coreclr+libs build (-c Debug
# -rc release -lc release -clrinterpreter) consumed by 4 SOS
# legs that run on top of it: cDAC, cDAC_fallback, cDAC_verify, DAC.
# -rc release -lc release -clrinterpreter) consumed by 3 SOS
# legs that run on top of it: cDAC, cDAC_verify, DAC.
# Each leg sets testInterpreter: true so interpreter coverage
# is exercised inline (no separate Interpreter leg).
#
Expand DownExpand Up@@ -177,13 +177,8 @@ extends:
name: cDAC
dacMode: cdac

# cDAC_fallback / cDAC_verify: the in-box DAC hosts the cDAC contract reader, with per-API fallback
# to the legacy DAC (fallback) or no fallback but still verifying against it (verify).
- template: /eng/pipelines/diagnostics/sos-test-leg.yml
parameters:
name: cDAC_fallback
dacMode: cdacfallback

# cDAC_verify: the in-box DAC hosts the cDAC contract reader without fallback,
# while still verifying against the legacy DAC.
- template: /eng/pipelines/diagnostics/sos-test-leg.yml
parameters:
name: cDAC_verify
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,15 +11,12 @@ namespace Microsoft.Diagnostics.DataContractReader.Legacy;

/// <summary>
/// Controls whether delegation-only APIs can fall back to the legacy DAC implementation.
/// When <c>CDAC_NO_FALLBACK=1</c> is set, only explicitly allowlisted methods may delegate.
/// Only explicitly allowlisted methods may delegate.
/// All fallback attempts are logged to stderr for capture by the test infrastructure.
/// </summary>
Comment thread
max-charlamb marked this conversation as resolved.
internal static class LegacyFallbackHelper
{
private static readonly bool s_noFallback =
Environment.GetEnvironmentVariable("CDAC_NO_FALLBACK") == "1";

// Methods that are allowed to fall back even in no-fallback mode.
// Methods that are allowed to fall back.
// Use the method name as it appears via [CallerMemberName].
private static readonly HashSet<string> s_allowlist = new(StringComparer.Ordinal)
{
Expand All@@ -36,18 +33,14 @@ internal static class LegacyFallbackHelper

/// <summary>
/// Returns <c>true</c> if the calling method is allowed to delegate to the legacy DAC.
/// In normal mode (no <c>CDAC_NO_FALLBACK</c>), always returns <c>true</c>.
/// In no-fallback mode, returns <c>true</c> only for allowlisted methods.
/// Returns <c>true</c> only for allowlisted methods.
/// All fallback attempts (allowed and blocked) are logged to stderr.
/// </summary>
internal static bool CanFallback(
[CallerMemberName] string name = "",
[CallerFilePath] string file = "",
[CallerLineNumber] int line = 0)
{
if (!s_noFallback)
return true;

if (s_allowlist.Contains(name) || s_fileAllowlist.Contains(Path.GetFileName(file)))
{
Console.Error.WriteLine($"[cDAC] Allowed fallback: {name} at {Path.GetFileName(file)}:{line}");
Expand Down