You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a game project right now, and I'm writing some relatively complex algorithms that heavily use Vectors. The actual code itself works fine but when i try to debug the code to find logical problems, the IDE debugger shows me wildly incorrect values for results of vector math operations(eg. Vector2.Zero * 1). This seems to happen with any vector, and any operation. Again, the actual values in the running code are fine, but the debugger shows something different.
Reproduction Steps
Vector2vec=newVector2(10,10);Console.WriteLine(vec*1);//some dummy code with a breakpoint
While stopped at breakpoint use ide tools to view result of operation directly (like hovering over the *) or run it in the repl.
Expected behavior
Displays the same number as whats printed to the console, <10,10>
Actual behavior
Displays the correct X value but a seemingly random Y value with no evident bound.
Regression?
No response
Known Workarounds
No response
Configuration
Building for .NET 10 using .NET sdk 10.0.201
MacOS 26.5 ARM64
Reproducible in both Jetbrains Rider and VScode
Not really. The debuggers are likely failing to handle the specialized data type in a similar way. It is a value that contains 2 fields and gets placed into a single register. Further, it is a SIMD register and not a General Purpose register which entails its own other special handling and considerations.
Root-caused this on macOS ARM64. It's a general HFA/HVA argument-marshalling bug in MethodDescCallSite::CallTargetWorker (src/coreclr/vm/callhelpers.cpp), not specific to SIMD or Vector2.
That function hand-marshals arguments into the register save area for func-eval. The branch that expands a struct-passed-in-registers into individual register slots is only compiled for UNIX_AMD64_ABI / LOONGARCH64 / RISCV64 — ARM64 was never added. So HFA arguments passed by value in FP registers fall into the default packed CopyMemory, which places the fields contiguously instead of one field per NEON register slot. The callee ends up reading {field0, field2, garbage, …}, which is exactly the "first lane right, rest garbage" symptom.
A few things worth noting:
It reproduces for any HFA argument, not just Vector2 — plain struct { float, float } and struct { double, double, double } are equally affected.
It's the argument path, not the return path. A method that builds an HFA purely from scalar args (MakeD3(1,2,3)) evaluates correctly; a method that takes an HFA (Scale(vec, 1)) does not.
It's "debugger only" because normal JIT-emitted calls and reflection invoke stubs don't use this manual marshalling path — debugger func-eval does.
Fix is a small ARM64 branch that calls the already-existing ArgDestination::CopyHFAStructToRegister (the same helper CopyValueClassArgUnchecked already uses). With it, vec * 1 → <10, 10> and all the other cases evaluate correctly. The code is shared, so this defect affects Windows/Linux ARM64 as well — macOS is just where it was reported. PR incoming.
Note
This analysis was produced with the assistance of GitHub Copilot.
Activity
dotnet-policy-service commentedon Apr 5, 2026
Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.
tannergooding commentedon Apr 6, 2026
This probably has to do with the respective debuggers, it does not reproduce in VS.
CC. @tommcdon
dotnet-policy-service commentedon Apr 6, 2026
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.
Atulin commentedon Apr 6, 2026
Odd that two different debuggers would have the same kind of bug tbh
tannergooding commentedon Apr 6, 2026
Not really. The debuggers are likely failing to handle the specialized data type in a similar way. It is a value that contains 2 fields and gets placed into a single register. Further, it is a SIMD register and not a General Purpose register which entails its own other special handling and considerations.
Atulin commentedon Apr 6, 2026
The issue does not seem to occur on Windows, at least when it comes to the Rider debugger:
huoyaoyuan commentedon Apr 6, 2026
For completeness, it doesn't reproduce on Windows ARM64 with VS.
steveisok commentedon Jul 12, 2026
Root-caused this on macOS ARM64. It's a general HFA/HVA argument-marshalling bug in
MethodDescCallSite::CallTargetWorker(src/coreclr/vm/callhelpers.cpp), not specific to SIMD orVector2.That function hand-marshals arguments into the register save area for func-eval. The branch that expands a struct-passed-in-registers into individual register slots is only compiled for
UNIX_AMD64_ABI/LOONGARCH64/RISCV64— ARM64 was never added. So HFA arguments passed by value in FP registers fall into the default packedCopyMemory, which places the fields contiguously instead of one field per NEON register slot. The callee ends up reading{field0, field2, garbage, …}, which is exactly the "first lane right, rest garbage" symptom.A few things worth noting:
Vector2— plainstruct { float, float }andstruct { double, double, double }are equally affected.MakeD3(1,2,3)) evaluates correctly; a method that takes an HFA (Scale(vec, 1)) does not.Fix is a small ARM64 branch that calls the already-existing
ArgDestination::CopyHFAStructToRegister(the same helperCopyValueClassArgUncheckedalready uses). With it,vec * 1→<10, 10>and all the other cases evaluate correctly. The code is shared, so this defect affects Windows/Linux ARM64 as well — macOS is just where it was reported. PR incoming.Note
This analysis was produced with the assistance of GitHub Copilot.
Fix HFA/HVA by-value argument marshalling on ARM64 in CallTargetWorker (