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
{{ message }}
Repository navigation
Constructing MD arrays in R2R code does not work on OSX/ARM64 #62747
We had other issues that could cause related test scenario (TestGenericMDArrayBehavior) to never run in R2R mode on OSX. #61938 makes R2R enabled more reliably on OSX, but now we see the test failing, so I disabled the scenario as a part of #61938.
I beleive the root cause is variadic JIT helper - HCIMPL2VA(Object*, JIT_NewMDArr, CORINFO_CLASS_HANDLE classHnd, unsigned dwNumArgs) .
It looks like OSX/ARM64 has special ABI for variadic calls, but we call it just as a cdecl with extra arguments. As a result the helper reads garbage and allocating MD arrays fails.
We do not use this helper in regular JIT code. There is a comment that it may be worth switching R2R to non-variadic helper as well since it would be more portable. Perhaps it is time?
The comment above the if block already says that the vararg helper is deprecated and should be removed in the future and that all usages should use the non-vararg method, but the non-vararg variant is only used in CoreRT for now as it requires an R2R version bump. As we're already bumping the R2R version with #61759, I think it would be okay to switch things over, but I'd want @jkotas to chime in here as well.
Activity
VSadov commentedon Dec 13, 2021
@dotnet/jit-contrib - is this a JIT issue?
filipnavara commentedon Dec 13, 2021
For reference, the general marshalling of varargs is tracked in #48796 with specific discussion about the macOS/iOS ABI situation.
jkoritzinsky commentedon Dec 13, 2021
I think this is a JIT issue.
It looks like there's two JIT helpers for creating MDArrays. One that uses varargs and one that doesn't.
For some reason it looks like the one that doesn't use varargs is only used in non-R2R or CoreRT scenarios:
Usage of the non-varag helper:
runtime/src/coreclr/jit/importer.cpp
Line 7501 in 4a48840
Condition for the block containing the non-vararg helper call setup:
runtime/src/coreclr/jit/importer.cpp
Line 7446 in 4a48840
Usage of the vararg helper (in the else block for the above
ifcondition):runtime/src/coreclr/jit/importer.cpp
Line 7518 in 4a48840
The comment above the
ifblock already says that the vararg helper is deprecated and should be removed in the future and that all usages should use the non-vararg method, but the non-vararg variant is only used in CoreRT for now as it requires an R2R version bump. As we're already bumping the R2R version with #61759, I think it would be okay to switch things over, but I'd want @jkotas to chime in here as well.VSadov commentedon Dec 13, 2021
Especially if we are already bumping R2R version.
Definitely a good time to get rid of a deprecated helper with poor portability.
jkotas commentedon Dec 14, 2021
+100
jkoritzinsky commentedon Dec 15, 2021
We're using a multidimensional array in ConsolePal.Unix.cs, so I think this is higher priority than we thought:
runtime/src/libraries/System.Console/src/System/ConsolePal.Unix.cs
Line 885 in fbabdb6
As a result, this is breaking all of the crossgen2 outerloop runs on macOS ARM64. I'll take a stab at fixing this to unblock the legs.