{"record":{"id":"c7e37f5a3c75d0e6","repo":"dotnet/BenchmarkDotNet","slug":"platform-is-not-supported","errorCode":null,"errorMessage":"{platform} is not supported","messagePattern":"(.+?) is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Disassemblers/ClrMdDisassembler.cs","lineNumber":28,"sourceCode":"{\n    internal abstract class ClrMdDisassembler\n\n    {\n        private static readonly ulong MinValidAddress = GetMinValidAddress();\n\n        private static ulong GetMinValidAddress()\n        {\n            // https://github.com/dotnet/BenchmarkDotNet/pull/2413#issuecomment-1688100117\n            if (OsDetector.IsWindows())\n                return ushort.MaxValue + 1;\n            if (OsDetector.IsLinux())\n                return (ulong)Environment.SystemPageSize;\n            if (OsDetector.IsMacOS())\n                return RuntimeInformation.GetCurrentPlatform() switch\n                {\n                    Environments.Platform.X86 or Environments.Platform.X64 => 4096,\n                    Environments.Platform.Arm64 => 0x100000000,\n                    var platform => throw new NotSupportedException($\"{platform} is not supported\")\n                };\n            throw new NotSupportedException($\"{System.Runtime.InteropServices.RuntimeInformation.OSDescription} is not supported\");\n        }\n\n        protected static bool IsValidAddress(ulong address)\n            // -1 (ulong.MaxValue) address is invalid, and will crash the runtime in older runtimes. https://github.com/dotnet/runtime/pull/90794\n            // 0 is NULL and therefore never valid.\n            // Addresses less than the minimum virtual address are also invalid.\n            => address != ulong.MaxValue\n                && address != 0\n                && address >= MinValidAddress;\n\n        // When ClrMD's GetMethodByInstructionPointer fails on a call target, the bytes at that\n        // address may be (a) a small JMP/B thunk the JIT inserted because the real callee was too\n        // far for a direct relative branch, or (b) a CoreCLR precode/stub (call-counting stub,\n        // stub precode, fixup precode) — the stable entry point for a tiered method. Architecture\n        // -specific subclasses decode their respective shapes and return the resolved target\n        // (the Target slot for precodes) so TryTranslateAddressToName can retry the lookup.","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Disassemblers/ClrMdDisassembler.cs#L10-L46","documentation":"GetMinValidAddress computes the lowest plausible virtual address the disassembler should consider. On macOS it branches on the current architecture: X86/X64 return 4096, Arm64 returns 0x100000000, and any other architecture (the switch's `var platform` discard) throws NotSupportedException. This is an architecture guard specific to macOS disassembly.","triggerScenarios":"Running the ClrMD disassembler on macOS on an architecture other than x86, x64, or Arm64 (e.g. a future Apple architecture or a misreported platform).","commonSituations":"New Apple Silicon variants, a runtime that reports an unexpected OSArchitecture, or running under Rosetta in a way that surfaces a different platform id.","solutions":["Run the disassembler on a supported macOS architecture (x64 or Arm64).","If disassembly is optional, disable the DisassemblyDiagnoser on unsupported architectures via a filter/platform guard.","Report the architecture to the BDN project if it is a legitimate new Apple platform so the switch can be extended.","Avoid forcing DisassemblyDiagnoser.UseBuiltInDisassembler on unverified hardware."],"exampleFix":"// before - diagnoser enabled unconditionally on all platforms\n.WithDisassembler(new ClrMdDisassembler(...))\n\n// after - gate on supported arch before enabling disassembly\nif (RuntimeInformation.OSArchitecture is Architecture.X64 or Architecture.Arm64)\n    config = config.WithDisassembler(new ClrMdDisassembler(...));","handlingStrategy":"fallback","validationCode":"if (RuntimeInformation.OSArchitecture is not (Architecture.X64 or Architecture.Arm64))\n    config = config.WithoutDisassembler(); // or do not add the DisassemblyDiagnoser","typeGuard":"static bool IsSupportedMacArch()\n    => RuntimeInformation.OSArchitecture is Architecture.X64 or Architecture.Arm64;","tryCatchPattern":"try { disassembler.AttachAndDisassemble(args); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"is not supported\") && OsDetector.IsMacOS())\n{\n    // fall back to running without disassembly on this architecture\n}","preventionTips":["Gate the DisassemblyDiagnoser on supported macOS architectures before enabling it.","Do not force built-in disassembly on unverified Apple hardware.","Report legitimately new Apple architectures upstream so the switch can be extended."],"tags":["disassembler","platform","macos","architecture","notsupported"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}