Notes
- This only seems to reproduce with the Release configuration, not Debug.
- This is just a targeted reproduction that was originally found when running this command from the repo root:
./build.sh clr.alljits+clr.tools+clr.nativeaotlibs+clr.nativeaotruntime+libs+libs.tests -rc Release -lc Release /p:TestNativeAot=true
- Originally found when trying to reproduce another issue: https://github.com/dotnet/runtime/issues/70010
Reproduction Steps
- On ARM64 Ubuntu 18.04
- Make sure bin artifacts are cleared out to rebuild
rm -rf /home/ubuntu/code/runtime/artifacts/bin/System.Reflection.Tests/
- Make sure obj artifacts are cleared out to rebuild
rm -rf /home/ubuntu/code/runtime/artifacts/obj/System.Reflection.Tests/
- Navigate to reflection tests
cd ~/code/runtime/src/libraries/System.Reflection/tests
- Run tests for NativeAOT
../../../../dotnet.sh build /t:Test /p:TestNativeAot=true -c Release -v d
Debugging Steps (after running Reproduction Steps):
- Setup symbols for debugging
cp /home/ubuntu/code/runtime/artifacts/bin/coreclr/Linux.arm64.Release/*.dbg /home/ubuntu/code/runtime/artifacts/bin/coreclr/Linux.arm64.Release/ilc
- Point gdb to ilc
gdb /home/ubuntu/code/runtime/artifacts/bin/coreclr/Linux.arm64.Release/ilc/ilc
- Tell gdb where symbols are
set debug-file-directory /home/ubuntu/code/runtime/artifacts/bin/coreclr/Linux.arm64.Release/ilc
- Run against reflection tests
r @"/home/ubuntu/code/runtime/artifacts/obj/System.Reflection.Tests/Release/net7.0/native/System.Reflection.Tests.ilc.rsp"
Error
Thread 37 ".NET ThreadPool" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xffbe66ffd1c0 (LWP 18899)]
GenTreeUseEdgeIterator::AdvanceCall<0> (this=0xffbe66ffb508) at /home/ubuntu/code/runtime/src/coreclr/jit/gentree.cpp:9650
9650 m_statePtr = arg->GetLateNext();
(gdb) bt
#0 GenTreeUseEdgeIterator::AdvanceCall<0> (this=0xffbe66ffb508) at /home/ubuntu/code/runtime/src/coreclr/jit/gentree.cpp:9650
#1 GenTreeUseEdgeIterator::GenTreeUseEdgeIterator (this=0xffbe66ffb508, node=0xffbe5c036db0) at /home/ubuntu/code/runtime/src/coreclr/jit/gentree.cpp:9357
#2 0x0000ffbe88221e44 in Compiler::fgGetFirstNode (tree=0xffbe5c036db0) at /home/ubuntu/code/runtime/src/coreclr/jit/flowgraph.cpp:4119
#3 0x0000ffbe882e6e30 in Rationalizer::RewriteNodeAsCall (this=0xffbe66ffb768, use=0xffbe5c037d08, parents=..., callHnd=<optimized out>, entryPoint=..., arg1=0xffbe5c031e50, arg2=0x0) at /home/ubuntu/code/runtime/src/coreclr/jit/rationalize.cpp:163
#4 0x0000ffbe882e81fc in Rationalizer::RewriteIntrinsicAsUserCall (this=0xffbe66ffb508, use=<optimized out>, parents=...) at /home/ubuntu/code/runtime/src/coreclr/jit/rationalize.cpp:244
#5 Rationalizer::DoPhase()::RationalizeVisitor::PreOrderVisit(GenTree**, GenTree*) (this=<optimized out>, use=<optimized out>, user=<optimized out>) at /home/ubuntu/code/runtime/src/coreclr/jit/rationalize.cpp:818
#6 GenTreeVisitor<Rationalizer::DoPhase()::RationalizeVisitor>::WalkTree(GenTree**, GenTree*) (this=<optimized out>, use=<optimized out>, user=<optimized out>) at /home/ubuntu/code/runtime/src/coreclr/jit/compiler.h:10673
#7 0x0000ffbe882e831c in GenTreeVisitor<Rationalizer::DoPhase()::RationalizeVisitor>::WalkTree(GenTree**, GenTree*) (this=<optimized out>, use=<optimized out>, user=<optimized out>) at /home/ubuntu/code/runtime/src/coreclr/jit/compiler.h:11013
#8 0x0000ffbe882e8048 in Rationalizer::DoPhase (this=0xffbe66ffb768) at /home/ubuntu/code/runtime/src/coreclr/jit/rationalize.cpp:888
#9 0x0000ffbe882e1fe0 in Phase::Run (this=0xffbe66ffb768) at /home/ubuntu/code/runtime/src/coreclr/jit/phase.cpp:61
#10 0x0000ffbe881f2110 in Compiler::compCompile (this=<optimized out>, methodCodePtr=<optimized out>, methodCodeSize=<optimized out>, compileFlags=<optimized out>) at /home/ubuntu/code/runtime/src/coreclr/jit/compiler.cpp:5029
#11 0x0000ffbe881f3658 in Compiler::compCompileHelper (this=0xffbe5c02e3b8, classPtr=<optimized out>, compHnd=<optimized out>, methodInfo=0xffbe66ffbe40, methodCodePtr=0xffbe66ffbc10, methodCodeSize=0xffbe66ffbe20, compileFlags=0xffbe66ffbc28)
at /home/ubuntu/code/runtime/src/coreclr/jit/compiler.cpp:6753
#12 0x0000ffbe881f2e10 in Compiler::compCompile(CORINFO_MODULE_STRUCT_*, void**, unsigned int*, JitFlags*)::$_11::operator()(Compiler::compCompile(CORINFO_MODULE_STRUCT_*, void**, unsigned int*, JitFlags*)::__JITParam*) const (this=<optimized out>, __JITpParam=<optimized out>)
at /home/ubuntu/code/runtime/src/coreclr/jit/compiler.cpp:5899
#13 Compiler::compCompile (this=0xffbe5c02e3b8, classPtr=0x436d80, methodCodePtr=0xffbe66ffbc10, methodCodeSize=0xffbe66ffbe20, compileFlags=0xffbe66ffbc28) at /home/ubuntu/code/runtime/src/coreclr/jit/compiler.cpp:5918
#14 0x0000ffbe881f3f2c in jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::$_13::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::__JITParam*) const::{lambda(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::$_13::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::__JITParam*) const::__JITParam*)#1}::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::$_13::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::__JITParam*) const::__JITParam*) const (this=<optimized out>, __JITpParam=<optimized out>)
at /home/ubuntu/code/runtime/src/coreclr/jit/compiler.cpp:7399
#15 jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::$_13::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::__JITParam*) const (this=<optimized out>, __JITpParam=<optimized out>) at /home/ubuntu/code/runtime/src/coreclr/jit/compiler.cpp:7424
#16 jitNativeCode (methodHnd=0x436d78, classPtr=0x436d80, compHnd=0xffbe66ffbc70, methodInfo=0xffbe66ffbe40, methodCodePtr=0xffbe66ffbc10, methodCodeSize=0xffbe66ffbe20, compileFlags=0xffbe66ffbc28, inlineInfoPtr=0x0)
at /home/ubuntu/code/runtime/src/coreclr/jit/compiler.cpp:7426
#17 0x0000ffbe881f80a8 in CILJit::compileMethod (this=<optimized out>, compHnd=0xffbe66ffbc70, methodInfo=0xffbe66ffbe40, flags=<optimized out>, entryAddress=<optimized out>, nativeSizeOfCode=0x420968) at /home/ubuntu/code/runtime/src/coreclr/jit/ee_il_dll.cpp:276
#18 0x0000ffbe8846f4d4 in JitCompileMethod (ppException=0xffbe66ffbe30, pJit=0xffbe884310d0 <operator new(unsigned long, CILJitSingletonAllocator const&)::CILJitBuff>, thisHandle=0xffbe66ffbe38, callbacks=<optimized out>, methodInfo=<optimized out>, flags=<optimized out>,
entryAddress=0xffbe66ffbe28, nativeSizeOfCode=0xffbe66ffbe20) at /home/ubuntu/code/runtime/src/coreclr/tools/aot/jitinterface/jitwrapper.cpp:34
#19 0x0000ffff8075ae1c in ?? ()
#20 0x0000fffff7a45328 in ?? () from /home/ubuntu/code/runtime/artifacts/bin/coreclr/Linux.arm64.Release/ilc/libcoreclr.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Looking at the dump clang’s codegen for
AdvanceCalllooks incorrect. it is skipping a null check that is present in the source code. In fact, it is missing a lot of code present in the source code due to assuming this null check always passes.I can see that the JIT in the dump you sent me is built with clang-6. Can you try a newer version of clang? The codegen for this function looks completely different for me using clang-9.
I’ll try to reproduce this again and get a dump next week.