VirtualBox

Changeset 66120 in vbox


Ignore:
Timestamp:
Mar 15, 2017 7:59:48 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114011
Message:

IPRT/RTThreadWait: Quick and dirty workaround for Ctrl-C deadlock with VirtualBox.exe.

Location:
trunk/src/VBox/Runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/thread.cpp

    r65620 r66120  
    11661166            if (pThread->fFlags & RTTHREADFLAGS_WAITABLE)
    11671167            {
    1168                 if (fAutoResume)
    1169                     rc = RTSemEventMultiWait(pThread->EventTerminated, cMillies);
     1168#if defined(IN_RING3) && defined(RT_OS_WINDOWS)
     1169                if (RT_LIKELY(rtThreadNativeIsAliveKludge(pThread)))
     1170#endif
     1171                {
     1172                    if (fAutoResume)
     1173                        rc = RTSemEventMultiWait(pThread->EventTerminated, cMillies);
     1174                    else
     1175                        rc = RTSemEventMultiWaitNoResume(pThread->EventTerminated, cMillies);
     1176                }
     1177#if defined(IN_RING3) && defined(RT_OS_WINDOWS)
    11701178                else
    1171                     rc = RTSemEventMultiWaitNoResume(pThread->EventTerminated, cMillies);
     1179                {
     1180                    rc = VINF_SUCCESS;
     1181                    if (pThread->rc == VERR_PROCESS_RUNNING)
     1182                        pThread->rc = VERR_THREAD_IS_DEAD;
     1183                }
     1184#endif
    11721185                if (RT_SUCCESS(rc))
    11731186                {
  • trunk/src/VBox/Runtime/include/internal/thread.h

    r62477 r66120  
    180180DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread);
    181181
     182#ifdef IN_RING3
     183/**
     184 * Called to check whether the thread is still alive or not before we start
     185 * waiting.
     186 *
     187 * This is a kludge to deal with windows threads being killed wholesale in
     188 * certain process termination scenarios and we don't want to hang the last
     189 * thread because it's waiting on the semaphore of a dead thread.
     190 *
     191 * @returns true if alive, false if not.
     192 * @param   pThread         The thread structure.
     193 */
     194DECLHIDDEN(bool) rtThreadNativeIsAliveKludge(PRTTHREADINT pThread);
     195#endif
     196
    182197#ifdef IN_RING0
    183198/**
  • trunk/src/VBox/Runtime/r3/win/thread-win.cpp

    r62592 r66120  
    3030*********************************************************************************************************************************/
    3131#define LOG_GROUP RTLOGGROUP_THREAD
    32 #include <iprt/win/windows.h>
     32#include <iprt/nt/nt-and-windows.h>
    3333
    3434#include <errno.h>
     
    279279
    280280
     281DECLHIDDEN(bool) rtThreadNativeIsAliveKludge(PRTTHREADINT pThread)
     282{
     283    PPEB_COMMON pPeb = NtCurrentPeb();
     284    if (!pPeb || !pPeb->Ldr || !pPeb->Ldr->ShutdownInProgress)
     285        return true;
     286    DWORD rcWait = WaitForSingleObject((HANDLE)pThread->hThread, 0);
     287    return rcWait != WAIT_OBJECT_0;
     288}
     289
     290
    281291RTDECL(RTTHREAD) RTThreadSelf(void)
    282292{
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette