VirtualBox

Ignore:
Timestamp:
Feb 22, 2015 11:29:25 PM (10 years ago)
Author:
vboxsync
Message:

IPRT/R0Drv: Fix (windows & solaris) / kludge (the rest) for thread termination racing IPRT termination race in ring-0.

File:
1 edited

Legend:

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

    r52457 r54358  
    7474*******************************************************************************/
    7575/** The AVL thread containing the threads. */
    76 static PAVLPVNODECORE   g_ThreadTree;
     76static PAVLPVNODECORE       g_ThreadTree;
     77/** The number of threads in the tree (for ring-0 termination kludge). */
     78static uint32_t volatile    g_cThreadInTree;
    7779#ifdef IN_RING3
    7880/** The RW lock protecting the tree. */
     
    455457                fRc = RTAvlPVInsert(&g_ThreadTree, &pThread->Core);
    456458                ASMAtomicOrU32(&pThread->fIntFlags, RTTHREADINT_FLAG_IN_TREE);
     459                if (fRc)
     460                    ASMAtomicIncU32(&g_cThreadInTree);
    457461
    458462                AssertReleaseMsg(fRc, ("Lock problem? %p (%RTnthrd) %s\n", pThread, NativeThread, pThread->szName));
     
    479483                                    pThread, pThread->Core.Key, pThread->szName));
    480484#endif
    481     NOREF(pThread2);
     485    if (pThread2)
     486        ASMAtomicDecU32(&g_cThreadInTree);
    482487}
    483488
     
    11761181                     */
    11771182                    if (ASMAtomicBitTestAndClear(&pThread->fFlags, RTTHREADFLAGS_WAITABLE_BIT))
     1183                    {
    11781184                        rtThreadRelease(pThread);
     1185#ifdef IN_RING0
     1186                        /*
     1187                         * IPRT termination kludge. Call native code to make sure
     1188                         * the last thread is really out of IPRT to prevent it from
     1189                         * crashing after we destroyed the spinlock in rtThreadTerm.
     1190                         */
     1191                        if (   ASMAtomicReadU32(&g_cThreadInTree) == 1
     1192                            && ASMAtomicReadU32(&pThread->cRefs) > 1)
     1193                            rtThreadNativeWaitKludge(pThread);
     1194#endif
     1195                    }
    11791196                }
    11801197            }
Note: See TracChangeset for help on using the changeset viewer.

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