Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
echesakov opened this issue Aug 5, 2020 · 3 comments · Fixed by #44547
Closed

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

echesakov opened this issue Aug 5, 2020 · 3 comments · Fixed by #44547
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@echesakov
Copy link
Contributor

echesakov commented Aug 5, 2020

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

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Aug 5, 2020
@echesakov
Copy link
Contributor Author

One more issue like this while compiling these methods

Unknown exception while compiling method System.Globalization.CalendarData.EnumCalendarInfo
Unknown exception while compiling method System.Globalization.CalendarData.CallEnumCalendarInfo
Unknown exception while compiling method System.Globalization.CalendarData.NlsGetCalendars
Unknown exception while compiling method System.Globalization.CultureData.NlsGetCultureDataFromRegionName
Unknown exception while compiling method System.Globalization.CultureData.nativeEnumTimeFormats
Unknown exception while compiling method System.Globalization.CultureData.NlsEnumCultures
Unknown exception while compiling method System.Globalization.CultureData.get_NlsIsReplacementCulture

The call stack

crossgen.exe!CEEInfo::getHelperName(CorInfoHelpFunc ftnNum) Line 3617
	at D:\git\runtime\src\coreclr\src\vm\jitinterface.cpp(3617)
clrjit.dll!Compiler::eeGetMethodName(CORINFO_METHOD_STRUCT_ * method, const char * * classNamePtr) Line 1223
	at D:\git\runtime\src\coreclr\src\jit\ee_il_dll.cpp(1223)
clrjit.dll!Compiler::eeGetMethodFullName(CORINFO_METHOD_STRUCT_ * hnd) Line 65
	at D:\git\runtime\src\coreclr\src\jit\eeinterface.cpp(65)
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 12309
	at D:\git\runtime\src\coreclr\src\jit\emitarm64.cpp(12309)
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 1666
	at D:\git\runtime\src\coreclr\src\jit\codegenarm64.cpp(1666)
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 62
	at D:\git\runtime\src\coreclr\src\jit\phase.cpp(62)
[Inline Frame] clrjit.dll!DoPhase(CodeGen *) Line 1619
	at D:\git\runtime\src\coreclr\src\jit\codegen.h(1619)
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)
[Inline Frame] clrjit.dll!Compiler::compCompile::__l61::__Body::Run(Compiler::compCompile::__l2::__JITParam *) 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)
[Inline Frame] clrjit.dll!jitNativeCode::__l8::__Body::Run::__l6::__Body::Run(jitNativeCode::__l8::__Body::Run::__l5::__JITParam *) 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 276
	at D:\git\runtime\src\coreclr\src\jit\ee_il_dll.cpp(276)
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()

points at

else if ((idFlags == GTF_ICON_METHOD_HDL) || (idFlags == GTF_ICON_FTN_ADDR))
{
targetName = emitComp->eeGetMethodFullName((CORINFO_METHOD_HANDLE)targetHandle);
}

that suggests that GTF_ICON_FTN_ADDR does not necessarily correspond to CORINFO_METHOD_HANDLE

@BruceForstall BruceForstall added this to the Future milestone Aug 5, 2020
@BruceForstall BruceForstall removed the untriaged New issue has not been triaged by the area owner label Aug 5, 2020
@BruceForstall BruceForstall modified the milestones: Future, 5.0.0 Aug 5, 2020
@BruceForstall
Copy link
Member

Marking this as 5.0 for now, although since it appears to only be for display, not a Release mode functionality issue, we can easily move it to Future.

@kunalspathak
Copy link
Member

Thanks for the analysis. Looks like it got introduced by my change in #38671. We can move it to Future because I want to make sure we still catch GTF_ICON_STATIC_HDL and GTF_ICON_FTN_ADDR cases.

@kunalspathak kunalspathak modified the milestones: 5.0.0, Future Aug 10, 2020
@BruceForstall BruceForstall added the JitUntriaged CLR JIT issues needing additional triage label Oct 28, 2020
@BruceForstall BruceForstall removed the JitUntriaged CLR JIT issues needing additional triage label Nov 11, 2020
@BruceForstall BruceForstall self-assigned this Nov 11, 2020
@BruceForstall BruceForstall modified the milestones: Future, 6.0.0 Nov 11, 2020
BruceForstall added a commit to BruceForstall/runtime that referenced this issue Nov 11, 2020
GTF_ICON_STATIC_HDL and GTF_ICON_FTN_ADDR can't be converted
to names using eeGetFieldName and eeGetMethodFullName, respectively.
So, just print out the type of the target.

Fixes dotnet#40354
BruceForstall added a commit that referenced this issue Nov 12, 2020
GTF_ICON_STATIC_HDL and GTF_ICON_FTN_ADDR can't be converted
to names using eeGetFieldName and eeGetMethodFullName, respectively.
So, just print out the type of the target.

Fixes #40354
@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants