Skip to content

[clr-ios] Fix interpreter NullReferenceException with Vector<T> on x64 ios simulator#129012

Open
kotlarmilos wants to merge 2 commits into
dotnet:mainfrom
kotlarmilos:fix-interp-vectort-128-mobile-x64
Open

[clr-ios] Fix interpreter NullReferenceException with Vector<T> on x64 ios simulator#129012
kotlarmilos wants to merge 2 commits into
dotnet:mainfrom
kotlarmilos:fix-interp-vectort-128-mobile-x64

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented Jun 4, 2026

Description

The interpreter only supports 128-bit Vector, but on Mac Catalyst and iOS simulator x64 it was ending up with 256-bit Vector, which is what caused the NullReferenceException in Vector.get_IsHardwareAccelerated. The runtime already limits Vector to 128-bit for the full interpreter mode, but it wasn't doing so on no-JIT builds where everything is interpreted anyway, so AVX2 on x64 silently bumped it up to 256-bit. This change applies the same 128-bit limit whenever the interpreter is the only thing running code. arm64 was never affected since Vector is always 128-bit there.

Fixes #128901

…-JIT x64

The interpreter only supports 128-bit Vector<T>, but on Mac Catalyst and
iOS simulator x64 it was ending up with 256-bit Vector<T>, which caused the
NullReferenceException in Vector.get_IsHardwareAccelerated. The runtime
already limits Vector<T> to 128-bit for the full interpreter mode, but it
wasn't doing so on no-JIT builds where everything is interpreted anyway, so
AVX2 on x64 silently bumped it up to 256-bit. Apply the same 128-bit limit
whenever the interpreter is the only thing running code. arm64 was never
affected since Vector<T> is always 128-bit there.

Related dotnet#128898

Fixes dotnet#128901

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 4, 2026 19:59
@kotlarmilos kotlarmilos changed the title [clr-ios] Fix interpreter NullReferenceException with Vector<T> on no-JIT x64 (Mac Catalyst / iOS simulator) [clr-ios] Fix interpreter NullReferenceException with Vector<T> on x64 ios simulator Jun 4, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts CoreCLR’s CPU feature initialization so that when execution is interpreter-only (either DOTNET_InterpMode=3 or when the runtime is built without dynamic code compilation/JIT), Vector<T> is constrained to 128-bit on x86/x64. This prevents the runtime from advertising/selecting 256-bit Vector<T> on AVX2-capable x64 machines in configurations where the interpreter can only handle 128-bit vectors.

Changes:

  • Detect “interpreter-only” operation as (InterpMode == 3) || !FEATURE_DYNAMIC_CODE_COMPILED.
  • Clamp EXTERNAL_MaxVectorTBitWidth to 128 in interpreter-only mode to prevent enabling InstructionSet_VectorT256/512.
  • Clamp EXTERNAL_PreferredVectorBitWidth to 128 in interpreter-only mode to keep vector-width preference consistent with interpreter constraints.
Show a summary per file
File Description
src/coreclr/vm/codeman.cpp Updates EEJitManager::SetCpuInfo() to force 128-bit Vector<T> sizing when the interpreter is the only execution engine (including no-JIT builds).

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@kotlarmilos kotlarmilos added this to the 11.0.0 milestone Jun 4, 2026
@kotlarmilos kotlarmilos added the os-ios Apple iOS label Jun 4, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

if (maxVectorTBitWidth != 128 && CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_InterpMode) == 3)
bool interpreterOnly = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_InterpMode) == 3;
#if !defined(FEATURE_DYNAMIC_CODE_COMPILED)
interpreterOnly = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the crossgen2 also limited to using 128 bit vectors when generating code for the x64 iOS? It seems both interpreter and crossgen2 needs to have the same view on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullReferenceException in System.Numerics.Vector.get_IsHardwareAccelerated()

3 participants