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

Func eval unreliable in .NET 5 due to Tiered JIT #37278

Closed
gregg-miskelly opened this issue Jun 1, 2020 · 1 comment · Fixed by #40060
Closed

Func eval unreliable in .NET 5 due to Tiered JIT #37278

gregg-miskelly opened this issue Jun 1, 2020 · 1 comment · Fixed by #40060

Comments

@gregg-miskelly
Copy link
Contributor

Description

Debugger func eval tests are flaky on .NET 5. After much investigation, the problem is this call to MethodDescBackpatchInfoTracker::IsLockOwnedByAnyThread.

That lock is owned by this thread:

Call stack for thread 0x21158:
Index  Function
--------------------------------------------------------------------------------
1      ntdll.dll!_ZwWaitForSingleObject@12()
2      KERNELBASE.dll!WaitForSingleObjectEx(void * hHandle, unsigned long dwMilliseconds, int bAlertable)
3      [Inline Frame] coreclr.dll!CLREventWaitHelper2(void *)
4      coreclr.dll!CLREventWaitHelper(void * handle, unsigned long dwMilliseconds, int alertable)
5      coreclr.dll!CLREventBase::WaitEx(unsigned long dwMilliseconds, WaitMode mode, PendingSync * syncState)
6      coreclr.dll!CLREventBase::Wait(unsigned long dwMilliseconds, int alertable, PendingSync * syncState)
7      coreclr.dll!Thread::WaitSuspendEventsHelper()
8      coreclr.dll!Thread::RareEnablePreemptiveGC()
---> 9      coreclr.dll!TieredCompilationManager::DeactivateTieringDelay()
10     coreclr.dll!TieredCompilationManager::TieringDelayTimerCallback(void * parameter, unsigned char timerFired)
11     coreclr.dll!ThreadpoolMgr::AsyncTimerCallbackCompletion(void * pArgs)
12     coreclr.dll!UnManagedPerAppDomainTPCount::DispatchWorkItem(bool * foundWork, bool * wasNotRecalled)
13     [Inline Frame] coreclr.dll!ThreadpoolMgr::ExecuteWorkRequest(bool *)
14     coreclr.dll!ThreadpoolMgr::WorkerThreadStart(void * lpArgs)
15     kernel32.dll!BaseThreadInitThunk(unsigned long RunProcessInit, long(__stdcall*)(void *) StartAddress, void * Argument)
16     ntdll.dll!__RtlUserThreadStart(long(__stdcall*)(void *) StartAddress, void * Argument)
17     ntdll.dll!_RtlUserThreadStart(long(__stdcall*)(void *) StartAddress, void * Argument)

Where I think the lock is acquired here:

MethodDescBackpatchInfoTracker::ConditionalLockHolder slotBackpatchLockHolder;

Regression?

Seems to be a new problem in .NET 5

@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 Jun 1, 2020
@jkotas jkotas added area-TieredCompilation-coreclr and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Jun 1, 2020
@jkotas
Copy link
Member

jkotas commented Jun 1, 2020

cc @kouvel

@jkotas jkotas added this to the 5.0 milestone Jun 1, 2020
@mangod9 mangod9 removed the untriaged New issue has not been triaged by the area owner label Jun 2, 2020
@kouvel kouvel self-assigned this Jun 3, 2020
@tommcdon tommcdon added the p1 label Jul 22, 2020
kouvel added a commit to kouvel/runtime that referenced this issue Jul 29, 2020
- Mostly reverted the previous workaround for the issue (commit fc06054)
- Added a forbid-suspend-for-debugger region in preemptive GC mode
- Added a crst holder type that acquires a lock and enters the forbid region
- Where the slot backpatching lock would be taken where cooperative GC mode may be entered inside that lock, the new crst holder is used
- When a suspend for debugger is requested, a thread in preemptive GC mode that is in the forbid region is considered not yet suspended and is synched later similarly to threads in cooperative GC mode

Fixes dotnet#37278
kouvel added a commit that referenced this issue Aug 4, 2020
…40060)

- Mostly reverted the previous workaround for the issue (commit fc06054)
- Added a forbid-suspend-for-debugger region in preemptive GC mode
- Added a crst holder type that acquires a lock and enters the forbid region
- Where the slot backpatching lock would be taken where cooperative GC mode may be entered inside that lock, the new crst holder is used
- When a suspend for debugger is requested, a thread in preemptive GC mode that is in the forbid region is considered not yet suspended and is synched later similarly to threads in cooperative GC mode

Fixes #37278
Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this issue Aug 10, 2020
…otnet#40060)

- Mostly reverted the previous workaround for the issue (commit fc06054)
- Added a forbid-suspend-for-debugger region in preemptive GC mode
- Added a crst holder type that acquires a lock and enters the forbid region
- Where the slot backpatching lock would be taken where cooperative GC mode may be entered inside that lock, the new crst holder is used
- When a suspend for debugger is requested, a thread in preemptive GC mode that is in the forbid region is considered not yet suspended and is synched later similarly to threads in cooperative GC mode

Fixes dotnet#37278
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants