Skip to content

ProcessInfo2 diagnostic pipe command can crash runtime instance if requested too early. #54083

Closed

Description

@jander-msft

Description

Issuing the new ProcessInfo2 command (see #52258) early in the lifetime of the target runtime process can cause it to crash and exit with exit code 0xC0000005.

Configuration

.NET 6.0.0-preview.6.21311.1
Windows x64

Regression?

Not a regression; the ProcessInfo2 command is new in 6.0.0 Preview 6.

Other information

Main thread call stack:

ntdll.dll!NtDelayExecution�()	Unknown	Non-user code. Symbols loaded.
KERNELBASE.dll!SleepEx()	Unknown	Non-user code. Symbols loaded.
[Inline Frame] coreclr.dll!ClrSleepEx(unsigned long) Line 259	C++	Symbols loaded.
coreclr.dll!Thread::UserSleep(int time) Line 4211	C++	Symbols loaded.
coreclr.dll!ThreadNative::Sleep(int iTime=1000) Line 469	C++	Symbols loaded.
System.Private.CoreLib.dll!00007ffafe1cea96()	Unknown	Non-user code. Native debugger skipped loading symbols for managed module.
00007ffa9ee4fdc2()	Unknown	Non-user code
00000000000003e8()	Unknown	Non-user code
000000325097e790()	Unknown	Non-user code
000001a381f06820()	Unknown	Non-user code
000001a38388e540()	Unknown	Non-user code
000000325097e870()	Unknown	Non-user code
000000325097eb08()	Unknown	Non-user code
000001a38388e910()	Unknown	Non-user code
0000000000000001()	Unknown	Non-user code
000000325097e870()	Unknown	Non-user code
coreclr.dll!CallDescrWorkerInternal�()	Unknown	Non-user code. Symbols loaded.
000001a381f06820()	Unknown	Non-user code
000000325097ebf0()	Unknown	Non-user code
000000325097ead0()	Unknown	Non-user code
000000325097e920()	Unknown	Non-user code
0000000000000008()	Unknown	Non-user code
000000325097eb08()	Unknown	Non-user code
[Inline Frame] coreclr.dll!CallDescrWorkerWithHandler(CallDescrData *) Line 71	C++	Symbols loaded.
coreclr.dll!MethodDescCallSite::CallTargetWorker(const unsigned __int64 * pArguments=0x000000325097eb08, unsigned __int64 * pReturnValue=0x0000000000000000, int cbReturnValue=8) Line 555	C++	Symbols loaded.
[Inline Frame] coreclr.dll!MetaSig::GetReturnType() Line 5231	C++	Symbols loaded.
[Inline Frame] coreclr.dll!MetaSig::IsReturnTypeVoid() Line 5237	C++	Symbols loaded.
coreclr.dll!MethodDesc::IsVoid() Line 1071	C++	Symbols loaded.
[Inline Frame] coreclr.dll!MethodDescCallSite::Call(const unsigned __int64 *) Line 458	C++	Symbols loaded.
coreclr.dll!RunMainInternal(Param * pParam=0x000000325097ead0) Line 1478	C++	Symbols loaded.
coreclr.dll!RunMain(MethodDesc * pFD=0x00007ffa9eef79d8, short piRetVal=0x0000000000000000, int * stringArgs=0x000000325097ef68, PtrArray * *) Line 1549	C++	Symbols loaded.
coreclr.dll!Assembly::ExecuteMainMethod(PtrArray * * stringArgs=0x0000000000000000, int) Line 1667	C++	Symbols loaded.
coreclr.dll!CorHost2::ExecuteAssembly(unsigned long dwAppDomainId, const wchar_t * pwzAssemblyPath=0x0000000000000001, int argc=0, const wchar_t * * argv=0x0000000000000000, unsigned long * pReturnValue=0x000000325097f190) Line 384	C++	Symbols loaded.
coreclr.dll!coreclr_execute_assembly(void * hostHandle=0x000001a381e6c750, unsigned int domainId=1, int argc=0, const char * * argv, const char * managedAssemblyPath=0x000001a381f41c00, unsigned int * exitCode=0x000000325097f190) Line 446	C++	Symbols loaded.
[Inline Frame] hostpolicy.dll!coreclr_t::execute_assembly(int) Line 89	C++	Symbols loaded.
hostpolicy.dll!run_app_for_context(const hostpolicy_context_t & context={...}, int argc=0, const wchar_t * * argv) Line 255	C++	Symbols loaded.
hostpolicy.dll!run_app(const int argc=0, const wchar_t * * argv=0x000001a381e5c140) Line 284	C++	Symbols loaded.
hostpolicy.dll!corehost_main(const int argc=2, const wchar_t * * argv=0x000001a381e5c130) Line 430	C++	Symbols loaded.
hostfxr.dll!execute_app(const std::wstring & impl_dll_dir, corehost_init_t * init=0x000001a381e6ad00, const int argc=2, const wchar_t * * argv=0x000001a381e5c130) Line 146	C++	Symbols loaded.
hostfxr.dll!`anonymous namespace'::read_config_and_execute(const std::wstring & host_command={...}, const host_startup_info_t & host_info, const std::wstring & app_candidate, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator<std::wstring>>,known_options_hash,std::equal_to<enum known_options>,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator<std::wstring>>>>> & opts, int new_argc=2, const wchar_t * * new_argv=0x000001a381e5c130, host_mode_t mode=muxer, wchar_t * out_buffer=0x0000000000000000, int buffer_size=0, int * required_buffer_size=0x0000000000000000) Line 520	C++	Symbols loaded.
hostfxr.dll!fx_muxer_t::handle_exec_host_command(const std::wstring & host_command={...}, const host_startup_info_t & host_info={...}, const std::wstring & app_candidate={...}, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator<std::wstring>>,known_options_hash,std::equal_to<enum known_options>,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator<std::wstring>>>>> & opts={...}, int argc=4, const wchar_t * * argv=0x000001a381e58dd0, int argoff=3, host_mode_t mode=muxer, wchar_t * result_buffer=0x0000000000000000, int buffer_size=0, int * required_buffer_size=0x0000000000000000) Line 1001	C++	Symbols loaded.
hostfxr.dll!fx_muxer_t::execute(const std::wstring host_command={...}, const int argc=4, const wchar_t * * argv=0x000001a381e58dd0, const host_startup_info_t & host_info={...}, wchar_t * result_buffer=0x0000000000000000, int buffer_size=0, int * required_buffer_size=0x0000000000000000) Line 566	C++	Symbols loaded.
hostfxr.dll!hostfxr_main_startupinfo(const int argc=4, const wchar_t * * argv=0x000001a381e58dd0, const wchar_t * host_path=0x000001a381e60ed0, const wchar_t * dotnet_root=0x000001a381e5e110, const wchar_t * app_path=0x000001a381e5f100) Line 61	C++	Symbols loaded.
dotnet.exe!exe_start(const int argc=4, const wchar_t * * argv=0x000001a381e58dd0) Line 236	C++	Symbols loaded.
dotnet.exe!wmain(const int argc, const wchar_t * * argv=0x000001a381e58dd0) Line 305	C++	Symbols loaded.
[Inline Frame] dotnet.exe!invoke_main() Line 90	C++	Non-user code. Symbols loaded.
dotnet.exe!__scrt_common_main_seh() Line 288	C++	Non-user code. Symbols loaded.
kernel32.dll!BaseThreadInitThunk�()	Unknown	Non-user code. Symbols loaded.
ntdll.dll!RtlUserThreadStart�()	Unknown	Non-user code. Symbols loaded.

Server thread call stack:

coreclr.dll!process_protocol_helper_get_process_info_2(_DiagnosticsIpcMessage * message=0x0000003250f7f790, _DiagnosticsIpcStream * stream=0x000001a381eebb60) Line 559	C++	Symbols loaded.
[Inline Frame] coreclr.dll!ds_process_protocol_helper_handle_ipc_message(_DiagnosticsIpcMessage *) Line 786	C++	Symbols loaded.
coreclr.dll!server_thread(void * data=0x0000000000000000) Line 164	C++	Symbols loaded.
kernel32.dll!BaseThreadInitThunk�()	Unknown	Non-user code. Symbols loaded.
ntdll.dll!RtlUserThreadStart�()	Unknown	Non-user code. Symbols loaded.

Exception details:

Unhandled exception thrown: read access violation.
AppDomain::m_pTheAppDomain->**m_pRootAssembly** was nullptr.

cc: @josalem

Activity

  1. ghost added
    untriaged
    on Jun 11, 2021
  2. josalem commented on Jun 11, 2021

    @josalem
    Contributor

    There's a window of time between the runtime starting and the host loading the first assembly where this field isn't populated and a suspended runtime happens to be waiting in that window. We'll need to adjust this command to either null out that field or fail sending it if the runtime hasn't been resumed.

  3. removed
    untriaged
    on Jun 11, 2021
  4. self-assigned this
    on Jun 11, 2021
  5. added this to the 6.0.0 milestone on Jun 11, 2021
  6. jander-msft commented on Jun 11, 2021

    @jander-msft
    ContributorAuthor

    There's a window of time between the runtime starting and the host loading the first assembly where this field isn't populated and a suspended runtime happens to be waiting in that window. We'll need to adjust this command to either null out that field or fail sending it if the runtime hasn't been resumed.

    If we end up failing the command, I would think it would be good to use a non-generic error code so that the client library can know to try again at a later time instead of giving up on it it completely. Ideally we'd still be able to successfully get a response from this command with the entrypoint information in it so that diagnostic tools in listening mode can set up monitoring based on the assembly name and then resume the runtime e.g. start a trace to get assembly load information for my application and not others.

  7. josalem commented on Jun 11, 2021

    @josalem
    Contributor

    If we don't already have an error code for "can't use this command while the runtime is suspended" then we can add one. I think there might already be one, but I'm not seeing it immediately.

  8. ghost added
    in-pr
    on Jul 9, 2021
  9. ghost locked as resolved and limited conversation to collaborators on Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-Diagnostics-coreclrin-pr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions