void CallFinalizer(Object* obj) { STATIC_CONTRACT_THROWS; STATIC_CONTRACT_GC_TRIGGERS; STATIC_CONTRACT_MODE_COOPERATIVE; MethodTable *pMT = obj->GetMethodTable(); STRESS_LOG2(LF_GC, LL_INFO1000, "Finalizing object %p MT %pT\n", obj, pMT); LOG((LF_GC, LL_INFO1000, "Finalizing " LOG_OBJECT_CLASS(obj))); _ASSERTE(GetThread()->PreemptiveGCDisabled()); // if we don't have a class, we can't call the finalizer // if the object has been marked run as finalizer run don't call either if (pMT) { if (!((obj->GetHeader()->GetBits()) & BIT_SBLK_FINALIZER_RUN)) { _ASSERTE(obj->GetMethodTable() == pMT); _ASSERTE(pMT->HasFinalizer() || pMT->IsTransparentProxy()); LogFinalization(obj); MethodTable::CallFinalizer(obj); } else { //reset the bit so the object can be put on the list //with RegisterForFinalization obj->GetHeader()->ClrBit (BIT_SBLK_FINALIZER_RUN); } } }
INT32 QCALLTYPE COMPrincipal::ImpersonateLoggedOnUser(HANDLE hToken) { QCALL_CONTRACT; HRESULT hr = S_OK; BEGIN_QCALL; #ifdef FEATURE_INCLUDE_ALL_INTERFACES IHostSecurityManager *pSM = CorHost2::GetHostSecurityManager(); if (pSM) { BEGIN_SO_TOLERANT_CODE_CALLING_HOST(GetThread()); hr = pSM->ImpersonateLoggedOnUser(hToken); END_SO_TOLERANT_CODE_CALLING_HOST; } else #endif // FEATURE_INCLUDE_ALL_INTERFACES { if (!::ImpersonateLoggedOnUser(hToken)) hr = HRESULT_FROM_GetLastError(); } STRESS_LOG2(LF_SECURITY, LL_INFO100, "COMPrincipal::ImpersonateLoggedOnUser called with hTokenSAFE = %d. Returning 0x%x\n",hToken,hr); END_QCALL; return hr; }
//----------------------------------------------------------------------------- // Real implementation of Canary Thread. // Single canary thread is reused after creation. //----------------------------------------------------------------------------- void HelperCanary::ThreadProc() { _ASSERTE(m_CanaryThreadId == GetCurrentThreadId()); while(true) { WaitForSingleObject(m_hPingEvent, INFINITE); m_AnswerCounter = 0; DWORD dwRequest = m_RequestCounter; if (m_fStop) { return; } STRESS_LOG2(LF_CORDB, LL_ALWAYS, "stage:%d,req:%d", 0, dwRequest); // Now take the locks of interest. This could block indefinitely. If this blocks, we may even get multiple requests. TakeLocks(); m_AnswerCounter = dwRequest; // Set wait event to let Requesting thread shortcut its spin lock. This is purely an // optimization because requesting thread will still check Answer/Request counters. // That protects us from recyling bugs. SetEvent(m_hWaitEvent); } }
VOID LogAssert( LPCSTR szFile, int iLine, LPCSTR szExpr ) { STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_GC_NOTRIGGER; STATIC_CONTRACT_SO_TOLERANT; STATIC_CONTRACT_DEBUG_ONLY; // Log asserts to the stress log. Note that we can't include the szExpr b/c that // may not be a string literal (particularly for formatt-able asserts). STRESS_LOG2(LF_ASSERT, LL_ALWAYS, "ASSERT:%s, line:%d\n", szFile, iLine); SYSTEMTIME st; #ifndef FEATURE_PAL GetLocalTime(&st); #else GetSystemTime(&st); #endif WCHAR exename[300]; WszGetModuleFileName(NULL, exename, sizeof(exename)/sizeof(WCHAR)); LOG((LF_ASSERT, LL_FATALERROR, "FAILED ASSERT(PID %d [0x%08x], Thread: %d [0x%x]) (%lu/%lu/%lu: %02lu:%02lu:%02lu %s): File: %s, Line %d : %s\n", GetCurrentProcessId(), GetCurrentProcessId(), GetCurrentThreadId(), GetCurrentThreadId(), (ULONG)st.wMonth, (ULONG)st.wDay, (ULONG)st.wYear, 1 + (( (ULONG)st.wHour + 11 ) % 12), (ULONG)st.wMinute, (ULONG)st.wSecond, (st.wHour < 12) ? "am" : "pm", szFile, iLine, szExpr)); LOG((LF_ASSERT, LL_FATALERROR, "RUNNING EXE: %ws\n", exename)); }