dotnet/BenchmarkDotNet · error · NotSupportedException

{System.Runtime.InteropServices.RuntimeInformation.OSDescrip

Error message

{System.Runtime.InteropServices.RuntimeInformation.OSDescription} is not supported

What it means

GetMinValidAddress first checks OsDetector for Windows, Linux, then macOS; if none match it throws NotSupportedException including RuntimeInformation.OSDescription. So this is the operating-system guard for the ClrMD disassembler's minimum-address logic: any OS outside Windows/Linux/macOS is unsupported.

Source

Thrown at src/BenchmarkDotNet/Disassemblers/ClrMdDisassembler.cs:30

    {
        private static readonly ulong MinValidAddress = GetMinValidAddress();

        private static ulong GetMinValidAddress()
        {
            // https://github.com/dotnet/BenchmarkDotNet/pull/2413#issuecomment-1688100117
            if (OsDetector.IsWindows())
                return ushort.MaxValue + 1;
            if (OsDetector.IsLinux())
                return (ulong)Environment.SystemPageSize;
            if (OsDetector.IsMacOS())
                return RuntimeInformation.GetCurrentPlatform() switch
                {
                    Environments.Platform.X86 or Environments.Platform.X64 => 4096,
                    Environments.Platform.Arm64 => 0x100000000,
                    var platform => throw new NotSupportedException($"{platform} is not supported")
                };
            throw new NotSupportedException($"{System.Runtime.InteropServices.RuntimeInformation.OSDescription} is not supported");
        }

        protected static bool IsValidAddress(ulong address)
            // -1 (ulong.MaxValue) address is invalid, and will crash the runtime in older runtimes. https://github.com/dotnet/runtime/pull/90794
            // 0 is NULL and therefore never valid.
            // Addresses less than the minimum virtual address are also invalid.
            => address != ulong.MaxValue
                && address != 0
                && address >= MinValidAddress;

        // When ClrMD's GetMethodByInstructionPointer fails on a call target, the bytes at that
        // address may be (a) a small JMP/B thunk the JIT inserted because the real callee was too
        // far for a direct relative branch, or (b) a CoreCLR precode/stub (call-counting stub,
        // stub precode, fixup precode) — the stable entry point for a tiered method. Architecture
        // -specific subclasses decode their respective shapes and return the resolved target
        // (the Target slot for precodes) so TryTranslateAddressToName can retry the lookup.
        // Best-effort: return false for anything we don't recognise (matches prior behaviour).
        protected abstract bool TryFollowJumpTrampoline(State state, ulong address, out ulong target);

View on GitHub (pinned to b515068b61)

Solutions

  1. Run disassembly on a supported OS (Windows, Linux, or macOS).
  2. Disable the DisassemblyDiagnoser on unsupported operating systems before running.
  3. If your OS is genuinely Linux-like but OsDetector misclassifies it, verify OsDetector.IsLinux() and report the detection bug.
  4. Use a different diagnoser that does not require ClrMD attachment on unsupported OSes.

Example fix

// before - disassembler always on
config.AddDiagnoser(new DisassemblyDiagnoser(...));

// after - gate disassembler on a supported OS
if (OsDetector.IsWindows() || OsDetector.IsLinux() || OsDetector.IsMacOS())
    config.AddDiagnoser(new DisassemblyDiagnoser(...));
Defensive patterns

Strategy: fallback

Validate before calling

if (!(OsDetector.IsWindows() || OsDetector.IsLinux() || OsDetector.IsMacOS()))
    config = config.WithoutDisassembler(); // unsupported OS for min-address logic

Type guard

static bool DisassemblerOsSupported()
    => OsDetector.IsWindows() || OsDetector.IsLinux() || OsDetector.IsMacOS();

Try / catch

try { disassembler.AttachAndDisassemble(args); }
catch (NotSupportedException ex) when (ex.Message.Contains("is not supported"))
{
    // disable disassembly for this run and continue without it
}

Prevention

When it happens

Trigger: Running the disassembler on an OS that OsDetector does not classify as Windows, Linux, or macOS (e.g. FreeBSD, illumos, or a platform where OsDetector detection fails).

Common situations: CI on niche Unix variants, containers with an unusual OSDescription string that defeats OsDetector, or a BSD-derived system.

Related errors


AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13). Data as JSON: /api/errors/0cf4627a86cb8e96. Report an issue: GitHub.