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
AF: (SIZE_T)mtype < COUNTOF(nativeSizes) when building COM vtable #53110
@jkotas we have reverted the original change showed the failure. Should we keep this issue open to fix from the runtime side? or you think nothing need to be done in the runtime side?
changed the title [-]CI Assert failure when starting System.Runtime.Tests[/-][+]AF: (SIZE_T)mtype < COUNTOF(nativeSizes) when building COM vtable[/+]on May 21, 2021
@jkoritzinsky Can you take a look at this. After taking a closer look here I agree with @jkotas that this should have failed in all cases. The field in question is a List<CultureInfo>. We are in a weird position here since we assert on x86 indicating the native type is unknown (correctly) whereas on Amd64 we don't perform the same field offset computation and just "do it".
The below code is why x86 is failing - specifically line 1040 because the MarshalInfo has determined the field is generic, marks the error resource ID, and sets the type as MARSHAL_TYPE_UNKNOWN. This is what asserts when trying to compute the native size of the field in MarshalInfo::GetNativeSize().
publicunsafeclassProgram{staticvoidMain(string[]args){varcontext=newEnumContext();EnumUILanguagesProcproc=EnumUiLanguagesCallback;EnumUILanguages(proc,MUI_ALL_INSTALLED_LANGUAGES|MUI_LANGUAGE_NAME,context);GC.KeepAlive(proc);}privatestaticboolEnumUiLanguagesCallback(IntPtrlpUiLanguageString,EnumContextlParam){Console.WriteLine($"{nameof(EnumUiLanguagesCallback)}");varcultureName=Marshal.PtrToStringUni(lpUiLanguageString);if(cultureName!=null){lParam.InstalledCultures.Add(CultureInfo.GetCultureInfo(cultureName));returntrue;}returnfalse;}privateconstuintMUI_LANGUAGE_NAME=0x8;privateconstuintMUI_ALL_INSTALLED_LANGUAGES=0x20;[DllImport("Kernel32.dll",CharSet=CharSet.Auto)]privatestaticexternboolEnumUILanguages(EnumUILanguagesProclpUILanguageEnumProc,uintdwFlags,EnumContextlParam);privatedelegateboolEnumUILanguagesProc(IntPtrlpUILanguageString,EnumContextlParam);privateclassEnumContext{// Marshalling this field is invalid but on Amd64 we ignore it and on x86// we assert or will index into random memory.publicreadonlyList<CultureInfo>InstalledCultures=new();}}
Activity
[-]CI Assert failure in System.Runtime.Tests[/-][+]CI Assert failure when starting System.Runtime.Tests[/+]jkotas commentedon May 21, 2021
The pattern leading to this assert: #52992 (comment)
Stack trace:
tarekgh commentedon May 21, 2021
@jkotas we have reverted the original change showed the failure. Should we keep this issue open to fix from the runtime side? or you think nothing need to be done in the runtime side?
jkotas commentedon May 21, 2021
Yes, we should keep this issue open to fix the assert.
[-]CI Assert failure when starting System.Runtime.Tests[/-][+]AF: (SIZE_T)mtype < COUNTOF(nativeSizes) when building COM vtable[/+]AaronRobinsonMSFT commentedon May 22, 2021
This has no issue on 64-bit. Just noticed the pointers are all 32-bit so switching to x86 build.
AaronRobinsonMSFT commentedon May 22, 2021
Confirmed this is only an x86 bug.
AaronRobinsonMSFT commentedon May 22, 2021
@jkoritzinsky Can you take a look at this. After taking a closer look here I agree with @jkotas that this should have failed in all cases. The field in question is a
List<CultureInfo>. We are in a weird position here since we assert on x86 indicating the native type is unknown (correctly) whereas on Amd64 we don't perform the same field offset computation and just "do it".The below code is why x86 is failing - specifically line 1040 because the
MarshalInfohas determined the field is generic, marks the error resource ID, and sets the type asMARSHAL_TYPE_UNKNOWN. This is what asserts when trying to compute the native size of the field inMarshalInfo::GetNativeSize().runtime/src/coreclr/vm/comtoclrcall.cpp
Lines 1016 to 1045 in 34dff2d
The repro is simple on Windows x86.