dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.16k stars 4.72k forks source link

[NativeAOT] Assertion failed 'node->IsUnusedValue() && "found an unmarked unused value"' - when compiling System.Net.Sockets.Tests #84112

Closed VSadov closed 1 year ago

VSadov commented 1 year ago
    // At this point the unusedDefs map should contain only unused values.
    if (checkUnusedValues)
    {
        for (auto kvp : unusedDefs)
        {
            GenTree* node = kvp.Key();
            assert(node->IsUnusedValue() && "found an unmarked unused value");      <==== here
            assert(!node->isContained() && "a contained node should have a user");
        }
    }
    KernelBase.dll!wil::details::DebugBreak(void)   Unknown
>   clrjit_win_x64_x64.dll!assertAbort(const char * why, const char * file, unsigned int line) Line 304 C++
    clrjit_win_x64_x64.dll!LIR::Range::CheckLIR(Compiler * compiler, bool checkUnusedValues) Line 1692  C++
    [Inline Frame] clrjit_win_x64_x64.dll!Lowering::CheckBlock(Compiler * compiler, BasicBlock *) Line 7351 C++
    [Inline Frame] clrjit_win_x64_x64.dll!Lowering::LowerBlock(BasicBlock *) Line 7382  C++
    clrjit_win_x64_x64.dll!Lowering::DoPhase() Line 7151    C++
    clrjit_win_x64_x64.dll!Phase::Run() Line 62 C++
    clrjit_win_x64_x64.dll!Compiler::compCompile(void * * methodCodePtr, unsigned int * methodCodeSize, JitFlags * compileFlags) Line 5088  C++
    clrjit_win_x64_x64.dll!Compiler::compCompileHelper(CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd, CORINFO_METHOD_INFO * methodInfo, void * * methodCodePtr, unsigned int * methodCodeSize, JitFlags * compileFlags) Line 7025    C++
    [Inline Frame] clrjit_win_x64_x64.dll!Compiler::compCompile::__l164::__Body::Run(Compiler::compCompile::__l2::__JITParam *) Line 6181   C++
    clrjit_win_x64_x64.dll!Compiler::compCompile(CORINFO_MODULE_STRUCT_ * classPtr, void * * methodCodePtr, unsigned int * methodCodeSize, JitFlags * compileFlags) Line 6185   C++
    [Inline Frame] clrjit_win_x64_x64.dll!jitNativeCode::__l8::__Body::Run::__l6::__Body::Run(jitNativeCode::__l8::__Body::Run::__l5::__JITParam *) Line 7668   C++
    clrjit_win_x64_x64.dll!`jitNativeCode'::`8'::__Body::Run(jitNativeCode::__l2::__JITParam * __JITpParam) Line 7671   C++
    clrjit_win_x64_x64.dll!jitNativeCode(CORINFO_METHOD_STRUCT_ * methodHnd, CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd, CORINFO_METHOD_INFO * methodInfo, void * * methodCodePtr, unsigned int * methodCodeSize, JitFlags * compileFlags, void * inlineInfoPtr) Line 7695    C++
    clrjit_win_x64_x64.dll!CILJit::compileMethod(ICorJitInfo * compHnd, CORINFO_METHOD_INFO * methodInfo, unsigned int flags, unsigned char * * entryAddress, unsigned int * nativeSizeOfCode) Line 272 C++
    jitinterface_x64.dll!JitCompileMethod(CorInfoExceptionClass * * ppException, ICorJitCompiler * pJit, void * thisHandle, void * * callbacks, CORINFO_METHOD_INFO * methodInfo, unsigned int flags, unsigned char * * entryAddress, unsigned int * nativeSizeOfCode) Line 34  C++
    ilc.exe!ILCompiler_RyuJit_Internal_JitInterface_CorInfoImpl__JitCompileMethod()    Unknown
    ilc.exe!ILCompiler_RyuJit_Internal_JitInterface_CorInfoImpl__CompileMethodInternal() Line 358   Unknown
    ilc.exe!ILCompiler_RyuJit_Internal_JitInterface_CorInfoImpl__CompileMethod() Line 62    Unknown
    ilc.exe!ILCompiler_RyuJit_ILCompiler_RyuJitCompilation__CompileSingleMethod_0() Line 190    Unknown
    ilc.exe!System_Threading_Tasks_Parallel_System_Threading_Tasks_Parallel___c__DisplayClass19_0_1<System___Canon>___ForWorker_b__1() Line 1060    Unknown
    ilc.exe!System_Threading_Tasks_Parallel_System_Threading_Tasks_TaskReplicator_Replica__Execute() Line 79    Unknown
    ilc.exe!S_P_CoreLib_System_Threading_ExecutionContext__RunFromThreadPoolDispatchLoop() Line 268 Unknown
    ilc.exe!S_P_CoreLib_System_Threading_Tasks_Task__ExecuteWithThreadLocal() Line 2353 Unknown
    ilc.exe!S_P_CoreLib_System_Threading_ThreadPoolWorkQueue__Dispatch() Line 919   Unknown
    ilc.exe!S_P_CoreLib_System_Threading_ThreadPool__DispatchCallback() Line 376    Unknown
ghost commented 1 year ago

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas See info in area-owners.md if you want to be subscribed.

Issue Details
null
Author: VSadov
Assignees: -
Labels: `area-NativeAOT-coreclr`
Milestone: -
ghost commented 1 year ago

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak See info in area-owners.md if you want to be subscribed.

Issue Details
```C // At this point the unusedDefs map should contain only unused values. if (checkUnusedValues) { for (auto kvp : unusedDefs) { GenTree* node = kvp.Key(); assert(node->IsUnusedValue() && "found an unmarked unused value"); <==== here assert(!node->isContained() && "a contained node should have a user"); } } ``` ``` KernelBase.dll!wil::details::DebugBreak(void) Unknown > clrjit_win_x64_x64.dll!assertAbort(const char * why, const char * file, unsigned int line) Line 304 C++ clrjit_win_x64_x64.dll!LIR::Range::CheckLIR(Compiler * compiler, bool checkUnusedValues) Line 1692 C++ [Inline Frame] clrjit_win_x64_x64.dll!Lowering::CheckBlock(Compiler * compiler, BasicBlock *) Line 7351 C++ [Inline Frame] clrjit_win_x64_x64.dll!Lowering::LowerBlock(BasicBlock *) Line 7382 C++ clrjit_win_x64_x64.dll!Lowering::DoPhase() Line 7151 C++ clrjit_win_x64_x64.dll!Phase::Run() Line 62 C++ clrjit_win_x64_x64.dll!Compiler::compCompile(void * * methodCodePtr, unsigned int * methodCodeSize, JitFlags * compileFlags) Line 5088 C++ clrjit_win_x64_x64.dll!Compiler::compCompileHelper(CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd, CORINFO_METHOD_INFO * methodInfo, void * * methodCodePtr, unsigned int * methodCodeSize, JitFlags * compileFlags) Line 7025 C++ [Inline Frame] clrjit_win_x64_x64.dll!Compiler::compCompile::__l164::__Body::Run(Compiler::compCompile::__l2::__JITParam *) Line 6181 C++ clrjit_win_x64_x64.dll!Compiler::compCompile(CORINFO_MODULE_STRUCT_ * classPtr, void * * methodCodePtr, unsigned int * methodCodeSize, JitFlags * compileFlags) Line 6185 C++ [Inline Frame] clrjit_win_x64_x64.dll!jitNativeCode::__l8::__Body::Run::__l6::__Body::Run(jitNativeCode::__l8::__Body::Run::__l5::__JITParam *) Line 7668 C++ clrjit_win_x64_x64.dll!`jitNativeCode'::`8'::__Body::Run(jitNativeCode::__l2::__JITParam * __JITpParam) Line 7671 C++ clrjit_win_x64_x64.dll!jitNativeCode(CORINFO_METHOD_STRUCT_ * methodHnd, CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd, CORINFO_METHOD_INFO * methodInfo, void * * methodCodePtr, unsigned int * methodCodeSize, JitFlags * compileFlags, void * inlineInfoPtr) Line 7695 C++ clrjit_win_x64_x64.dll!CILJit::compileMethod(ICorJitInfo * compHnd, CORINFO_METHOD_INFO * methodInfo, unsigned int flags, unsigned char * * entryAddress, unsigned int * nativeSizeOfCode) Line 272 C++ jitinterface_x64.dll!JitCompileMethod(CorInfoExceptionClass * * ppException, ICorJitCompiler * pJit, void * thisHandle, void * * callbacks, CORINFO_METHOD_INFO * methodInfo, unsigned int flags, unsigned char * * entryAddress, unsigned int * nativeSizeOfCode) Line 34 C++ ilc.exe!ILCompiler_RyuJit_Internal_JitInterface_CorInfoImpl__JitCompileMethod() Unknown ilc.exe!ILCompiler_RyuJit_Internal_JitInterface_CorInfoImpl__CompileMethodInternal() Line 358 Unknown ilc.exe!ILCompiler_RyuJit_Internal_JitInterface_CorInfoImpl__CompileMethod() Line 62 Unknown ilc.exe!ILCompiler_RyuJit_ILCompiler_RyuJitCompilation__CompileSingleMethod_0() Line 190 Unknown ilc.exe!System_Threading_Tasks_Parallel_System_Threading_Tasks_Parallel___c__DisplayClass19_0_1___ForWorker_b__1() Line 1060 Unknown ilc.exe!System_Threading_Tasks_Parallel_System_Threading_Tasks_TaskReplicator_Replica__Execute() Line 79 Unknown ilc.exe!S_P_CoreLib_System_Threading_ExecutionContext__RunFromThreadPoolDispatchLoop() Line 268 Unknown ilc.exe!S_P_CoreLib_System_Threading_Tasks_Task__ExecuteWithThreadLocal() Line 2353 Unknown ilc.exe!S_P_CoreLib_System_Threading_ThreadPoolWorkQueue__Dispatch() Line 919 Unknown ilc.exe!S_P_CoreLib_System_Threading_ThreadPool__DispatchCallback() Line 376 Unknown ```
Author: VSadov
Assignees: -
Labels: `area-CodeGen-coreclr`, `untriaged`, `area-NativeAOT-coreclr`
Milestone: -
VSadov commented 1 year ago

I will disable the offending test. Just need to be sure it is the only one affected.

VSadov commented 1 year ago

This must be a relatively recent issue. I run tests with chk runtime frequently and did not see it. However my base (5d88ff404de77d78e07ad3de7fa2af270332da22) was a few days old. The issue must be newer than that commit.

VSadov commented 1 year ago

This is the only test affected. With System.Net.Sockets.Tests excluded chk/ret NativeAOT Libraries tests pass locally.

EgorBo commented 1 year ago

@VSadov can you please remind me how do I build a specific BCL test suite with NAOT? I think last time I tried it only worked for the whole BCL suite and took several hours

VSadov commented 1 year ago

I think last time I tried it only worked for the whole BCL suite and took several hours

I takes about 12-15 minutes to run the whole suite on AMD 5950X from clean state, so it is not too bad. I run the whole suite fairly often. It does need a fast machine with lots of memory though.

There were some instructions for selective compiling/running tests in https://github.com/dotnet/runtime/issues/78717

jkotas commented 1 year ago
build.cmd -s clr.aot+libs -rc checked -c Release
cd src\libraries\System.Net.Sockets\tests\FunctionalTests
..\..\..\..\..\dotnet.cmd build /t:Test -c Release /p:TestNativeAot=true /p:CoreCLRConfiguration=checked
VSadov commented 1 year ago

@EgorBo - FYI. The test has been disabled on NativeAOT in https://github.com/dotnet/runtime/pull/84114. If you decide to run the whole suite, you'd need to sync to before that change.

(also if you decide to run the whole suite on your new machine 🚀, do share how long it took. ;)