Add timeout routine for evaluation.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Thu, 14 May 2020 15:44:10 +0000 (18:44 +0300)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Thu, 21 May 2020 21:27:05 +0000 (06:27 +0900)
src/debug/netcoredbg/valuewalk.cpp

index ffba14cc0eaa3f220f24bc9fac26645380c79828..2151a1c1565b91d4441172c78c88ff6503c44806 100644 (file)
@@ -115,6 +115,33 @@ HRESULT Evaluator::WaitEvalResult(ICorDebugThread *pThread,
         if (!f.valid())
             return E_FAIL;
 
+        // NOTE
+        // MSVS 2017 debugger and newer use config file
+        // C:\Program Files (x86)\Microsoft Visual Studio\YYYY\VERSION\Common7\IDE\Profiles\CSharp.vssettings
+        // by default NormalEvalTimeout is 5000 milliseconds
+        //
+        // TODO add timeout configuration feature (care about VSCode, MSVS with Tizen plugin, standalone usage)
+
+        std::future_status timeoutStatus = f.wait_for(std::chrono::milliseconds(5000));
+        if (timeoutStatus == std::future_status::timeout)
+        {
+            Logger::levelLog(LOG_WARN, "Evaluation timed out.");
+
+            // NOTE
+            // Call ICorDebugEval::Abort() and ICorDebugEval2::RudeAbort() during process execution is allowed, we are safe here.
+            // 
+            // All CoreCLR releases at least till version 3.1.3, don't have proper x86 implementation for ICorDebugEval::Abort().
+            // This issue looks like CoreCLR terminate managed process execution instead of abort evaluation.
+
+            if (FAILED(pEval->Abort()))
+            {
+                HRESULT Status = S_OK;
+                ToRelease<ICorDebugEval2> pEval2;
+                IfFailRet(pEval->QueryInterface(IID_ICorDebugEval2, (LPVOID*) &pEval2));
+                IfFailRet(pEval2->RudeAbort());
+            }
+        }
+
         auto evalResult = f.get();
 
         if (!ppEvalResult)