Skip to content

[cDAC] CallingConventionInfo cannot distinguish Apple ARM64 from Linux ARM64 #127282

@max-charlamb

Description

@max-charlamb

Description

CallingConventionInfo (#126408) in the cDAC cannot reliably distinguish Apple ARM64 (macOS/iOS) from Linux ARM64, because RuntimeInfoOperatingSystem only has Unix — which covers both platforms.

Apple ARM64 has different stack alignment rules than Linux ARM64 (Apple uses natural alignment for primitives and 4-byte alignment for float HFAs on the stack, while Linux uses 8-byte alignment for everything). Applying the wrong rules produces incorrect argument offset calculations in ArgIterator.

Current State

IsAppleArm64ABI is hardcoded to false to avoid applying Apple-specific rules on Linux. This means Apple ARM64 stack layout may be slightly incorrect for value types passed on the stack.

Proposed Fix

Add a reliable Apple platform discriminator to IRuntimeInfo (or add a new global/data descriptor), such as:

  • RuntimeInfoOperatingSystem.Apple or RuntimeInfoOperatingSystem.MacOS
  • A boolean global IsApplePlatform
  • Inferring from the target's OS name string

Then update CallingConventionInfo to set IsAppleArm64ABI = true only when the target is confirmed to be an Apple platform.

Files

  • src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/CallingConvention/CallingConventionInfo.cs
  • src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeInfo.cs

Note

This issue was created with AI assistance from Copilot.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions