Skip to content

[Arm64] Crossgen fails to compile some methods with NGenDump enabled #40354

@echesakov

Description

@echesakov

When running jit-diff with Hostx64/arm64 crossgen with COMPlus_NGenDump=* the following appears in the crossgen output

Unknown exception while compiling method System.Char.get_Latin1CharInfo
Unknown exception while compiling method System.Char.GetLatin1UnicodeCategory
Unknown exception while compiling method System.Char.IsLetter
Unknown exception while compiling method System.Char.IsWhiteSpaceLatin1
Unknown exception while compiling method System.Char.IsUpper
Unknown exception while compiling method System.Char.IsLower
Unknown exception while compiling method System.Char.IsLetter
Unknown exception while compiling method System.Char.IsLower
Unknown exception while compiling method System.Char.IsUpper
Unknown exception while compiling method System.Convert.TryDecodeFromUtf16
Unknown exception while compiling method System.Convert.get_DecodingMap
Unknown exception while compiling method System.Guid.TryParseHex
(84 methods in total)

Under debugger the following call stack

crossgen.exe!MethodTable::GetModule() Line 378
	at D:\git\runtime\src\coreclr\src\vm\methodtable.cpp(378)
[Inline Frame] crossgen.exe!FieldDesc::GetModule() Line 606
	at D:\git\runtime\src\coreclr\src\vm\field.h(606)
[Inline Frame] crossgen.exe!FieldDesc::GetMDImport() Line 738
	at D:\git\runtime\src\coreclr\src\vm\field.h(738)
crossgen.exe!FieldDesc::GetName() Line 670
	at D:\git\runtime\src\coreclr\src\vm\field.h(670)
clrjit.dll!`Compiler::eeGetFieldName'::`3'::__Body::Run(FilterSuperPMIExceptionsParam_ee_il * pParam) Line 1282
	at D:\git\runtime\src\coreclr\src\jit\ee_il_dll.cpp(1282)
clrjit.dll!Compiler::eeGetFieldName(CORINFO_FIELD_STRUCT_ * field, const char * * classNamePtr) Line 1285
	at D:\git\runtime\src\coreclr\src\jit\ee_il_dll.cpp(1285)
clrjit.dll!emitter::emitDispIns(emitter::instrDesc * id, bool isNew, bool doffs, bool asmfm, unsigned int offset, unsigned char * pCode, unsigned __int64 sz, insGroup * ig) Line 12304
	at D:\git\runtime\src\coreclr\src\jit\emitarm64.cpp(12304)
clrjit.dll!emitter::dispIns(emitter::instrDesc * id) Line 1191
	at D:\git\runtime\src\coreclr\src\jit\emit.cpp(1191)
clrjit.dll!emitter::emitIns_R_AI(instruction ins, emitAttr attr, _regNumber_enum ireg, __int64 addr, unsigned __int64 targetHandle, unsigned int gtFlags) Line 8038
	at D:\git\runtime\src\coreclr\src\jit\emitarm64.cpp(8038)
clrjit.dll!CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, _regNumber_enum reg, __int64 imm, insFlags flags, unsigned __int64 targetHandle, unsigned int gtFlags) Line 1592
	at D:\git\runtime\src\coreclr\src\jit\codegenarm64.cpp(1592)
clrjit.dll!CodeGen::genSetRegToConst(_regNumber_enum targetReg, var_types targetType, GenTree * tree) Line 1691
	at D:\git\runtime\src\coreclr\src\jit\codegenarm64.cpp(1691)
clrjit.dll!CodeGen::genCodeForTreeNode(GenTree * treeNode) Line 183
	at D:\git\runtime\src\coreclr\src\jit\codegenarmarch.cpp(183)
clrjit.dll!CodeGen::genCodeForBBlist() Line 457
	at D:\git\runtime\src\coreclr\src\jit\codegenlinear.cpp(457)
clrjit.dll!CodeGen::genGenerateMachineCode() Line 2242
	at D:\git\runtime\src\coreclr\src\jit\codegencommon.cpp(2242)
clrjit.dll!CodeGenPhase::DoPhase() Line 1606
	at D:\git\runtime\src\coreclr\src\jit\codegen.h(1606)
clrjit.dll!Phase::Run() Line 61
	at D:\git\runtime\src\coreclr\src\jit\phase.cpp(61)
clrjit.dll!DoPhase(CodeGen * _codeGen, Phases _phase, void(CodeGen::*)() _action) Line 1620
	at D:\git\runtime\src\coreclr\src\jit\codegen.h(1620)
clrjit.dll!CodeGen::genGenerateCode(void * * codePtr, unsigned long * nativeSizeOfCode) Line 2052
	at D:\git\runtime\src\coreclr\src\jit\codegencommon.cpp(2052)
clrjit.dll!Compiler::compCompile(void * * methodCodePtr, unsigned long * methodCodeSize, JitFlags * compileFlags) Line 4945
	at D:\git\runtime\src\coreclr\src\jit\compiler.cpp(4945)
clrjit.dll!Compiler::compCompileHelper(CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd, CORINFO_METHOD_INFO * methodInfo, void * * methodCodePtr, unsigned long * methodCodeSize, JitFlags * compileFlags) Line 6131
	at D:\git\runtime\src\coreclr\src\jit\compiler.cpp(6131)
clrjit.dll!`Compiler::compCompile'::`61'::__Body::Run(Compiler::compCompile::__l2::__JITParam * __JITpParam) Line 5466
	at D:\git\runtime\src\coreclr\src\jit\compiler.cpp(5466)
clrjit.dll!Compiler::compCompile(CORINFO_MODULE_STRUCT_ * classPtr, void * * methodCodePtr, unsigned long * methodCodeSize, JitFlags * compileFlags) Line 5470
	at D:\git\runtime\src\coreclr\src\jit\compiler.cpp(5470)
clrjit.dll!``jitNativeCode'::`8'::__Body::Run'::`6'::__Body::Run(jitNativeCode::__l8::__Body::Run::__l5::__JITParam * __JITpParam) Line 6770
	at D:\git\runtime\src\coreclr\src\jit\compiler.cpp(6770)
clrjit.dll!`jitNativeCode'::`8'::__Body::Run(jitNativeCode::__l2::__JITParam * __JITpParam) Line 6773
	at D:\git\runtime\src\coreclr\src\jit\compiler.cpp(6773)
clrjit.dll!jitNativeCode(CORINFO_METHOD_STRUCT_ * methodHnd, CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd, CORINFO_METHOD_INFO * methodInfo, void * * methodCodePtr, unsigned long * methodCodeSize, JitFlags * compileFlags, void * inlineInfoPtr) Line 6797
	at D:\git\runtime\src\coreclr\src\jit\compiler.cpp(6797)
clrjit.dll!CILJit::compileMethod(ICorJitInfo * compHnd, CORINFO_METHOD_INFO * methodInfo, unsigned int flags, unsigned char * * entryAddress, unsigned long * nativeSizeOfCode) Line 273
	at D:\git\runtime\src\coreclr\src\jit\ee_il_dll.cpp(273)
crossgen.exe!ZapInfo::CompileMethod() Line 538
	at D:\git\runtime\src\coreclr\src\zap\zapinfo.cpp(538)
crossgen.exe!ZapImage::TryCompileMethodWorker(CORINFO_METHOD_STRUCT_ * handle, unsigned int md, unsigned int methodProfilingDataFlags) Line 2134
	at D:\git\runtime\src\coreclr\src\zap\zapimage.cpp(2134)
crossgen.exe!ZapImage::TryCompileMethodDef(unsigned int md, unsigned int methodProfilingDataFlags) Line 1955
	at D:\git\runtime\src\coreclr\src\zap\zapimage.cpp(1955)
crossgen.exe!ZapImage::CompileColdRegion() Line 1730
	at D:\git\runtime\src\coreclr\src\zap\zapimage.cpp(1730)
crossgen.exe!ZapImage::Compile() Line 1790
	at D:\git\runtime\src\coreclr\src\zap\zapimage.cpp(1790)
crossgen.exe!Zapper::CompileModule(CORINFO_MODULE_STRUCT_ * hModule, IMetaDataAssemblyEmit * pAssemblyEmit) Line 1479
	at D:\git\runtime\src\coreclr\src\zap\zapper.cpp(1479)
crossgen.exe!Zapper::CompileAssembly(_GUID * pNativeImageSig) Line 1365
	at D:\git\runtime\src\coreclr\src\zap\zapper.cpp(1365)
crossgen.exe!Zapper::CompileInCurrentDomain(const wchar_t * string, _GUID * pNativeImageSig) Line 1069
	at D:\git\runtime\src\coreclr\src\zap\zapper.cpp(1069)
crossgen.exe!Zapper::Compile(const wchar_t * string, _GUID * pNativeImageSig) Line 999
	at D:\git\runtime\src\coreclr\src\zap\zapper.cpp(999)
crossgen.exe!NGenWorker(const wchar_t * pwzFilename, unsigned long dwFlags, const wchar_t * pwzPlatformAssembliesPaths, const wchar_t * pwzTrustedPlatformAssemblies, const wchar_t * pwzPlatformResourceRoots, const wchar_t * pwzAppPaths, const wchar_t * pwzOutputFilename, unsigned __int64 customBaseAddress, ICorSvcLogger * pLogger, const wchar_t * pwszCLRJITPath) Line 109
	at D:\git\runtime\src\coreclr\src\zap\zapper.cpp(109)
crossgen.exe!wmain(int argc, wchar_t * * argv) Line 912
	at D:\git\runtime\src\coreclr\src\tools\crossgen\crossgen.cpp(912)
crossgen.exe!invoke_main() Line 91
	at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(91)
crossgen.exe!__scrt_common_main_seh() Line 288
	at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288)
crossgen.exe!__scrt_common_main() Line 331
	at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331)
crossgen.exe!wmainCRTStartup() Line 17
	at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_wmain.cpp(17)
kernel32.dll!00007ff951547bd4()
ntdll.dll!00007ff9533ace51()

suggests that in

https://github.com/dotnet/runtime/blob/646cfa33683482eb6acacb69b6a4ea6a9af6ce0f/src/coreclr/src/jit/emitarm64.cpp#L12302-L12304

the assumption that GTF_ICON_STATIC_HDL refers to static fields is incorrect.

In this particular case (System.Char.get_Latin1CharInfo), the static handle is address of the following byte array in

https://github.com/dotnet/runtime/blob/646cfa33683482eb6acacb69b6a4ea6a9af6ce0f/src/libraries/System.Private.CoreLib/src/System/Char.cs#L55-L73

(Note: there's some kind of GitHub bug where if you don't quote the above source links, it's impossible to update this comment)

category:correctness
theme:debug-dumps
skill-level:beginner
cost:small

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions