VirtualBox

Changeset 34256 in vbox for trunk


Ignore:
Timestamp:
Nov 22, 2010 3:55:00 PM (14 years ago)
Author:
vboxsync
Message:

IPRT: Must clear the TLS entry holding RTTHREAD before freeing the structure or the electric fence heap may cause a crash when blocking.

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

Legend:

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

    r30112 r34256  
    604604        RTSemEventMultiDestroy(hEvt2);
    605605
     606    rtThreadNativeDestroy(pThread);
    606607    RTMemFree(pThread);
    607608}
  • trunk/src/VBox/Runtime/include/internal/thread.h

    r33540 r34256  
    159159
    160160/**
     161 * Called from rtThreadDestroy so that the TLS entry and any native data in the
     162 * thread structure can be cleared.
     163 *
     164 * @param   pThread         The thread structure.
     165 */
     166void rtThreadNativeDestroy(PRTTHREADINT pThread);
     167
     168/**
    161169 * Sets the priority of the thread according to the thread type
    162170 * and current process priority.
     
    186194
    187195/* thread.cpp */
    188 int rtThreadMain(PRTTHREADINT pThread, RTNATIVETHREAD NativeThread, const char *pszThreadName);
    189 void rtThreadBlocking(PRTTHREADINT pThread, RTTHREADSTATE enmState, uint64_t u64Block,
    190                       const char *pszFile, unsigned uLine, RTUINTPTR uId);
    191 void rtThreadUnblocked(PRTTHREADINT pThread, RTTHREADSTATE enmCurState);
    192 uint32_t rtThreadRelease(PRTTHREADINT pThread);
    193 void rtThreadTerminate(PRTTHREADINT pThread, int rc);
     196int          rtThreadMain(PRTTHREADINT pThread, RTNATIVETHREAD NativeThread, const char *pszThreadName);
     197void         rtThreadBlocking(PRTTHREADINT pThread, RTTHREADSTATE enmState, uint64_t u64Block,
     198                              const char *pszFile, unsigned uLine, RTUINTPTR uId);
     199void         rtThreadUnblocked(PRTTHREADINT pThread, RTTHREADSTATE enmCurState);
     200uint32_t     rtThreadRelease(PRTTHREADINT pThread);
     201void         rtThreadTerminate(PRTTHREADINT pThread, int rc);
    194202PRTTHREADINT rtThreadGetByNative(RTNATIVETHREAD NativeThread);
    195203PRTTHREADINT rtThreadGet(RTTHREAD Thread);
    196 int rtThreadInit(void);
    197 void rtThreadTerm(void);
    198 void rtThreadInsert(PRTTHREADINT pThread, RTNATIVETHREAD NativeThread);
    199 #ifdef IN_RING3
    200 int rtThreadDoSetProcPriority(RTPROCPRIORITY enmPriority);
     204int          rtThreadInit(void);
     205void         rtThreadTerm(void);
     206void         rtThreadInsert(PRTTHREADINT pThread, RTNATIVETHREAD NativeThread);
     207#ifdef IN_RING3
     208int          rtThreadDoSetProcPriority(RTPROCPRIORITY enmPriority);
    201209#endif /* !IN_RING0 */
    202210#ifdef IPRT_WITH_GENERIC_TLS
    203 void rtThreadClearTlsEntry(RTTLS iTls);
    204 void rtThreadTlsDestruction(PRTTHREADINT pThread); /* in tls-generic.cpp */
     211void         rtThreadClearTlsEntry(RTTLS iTls);
     212void         rtThreadTlsDestruction(PRTTHREADINT pThread); /* in tls-generic.cpp */
    205213#endif
    206214
  • trunk/src/VBox/Runtime/r0drv/darwin/thread2-r0drv-darwin.cpp

    r29255 r34256  
    137137
    138138
     139void rtThreadNativeDestroy(PRTTHREADINT pThread)
     140{
     141    NOREF(pThread);
     142}
     143
     144
    139145/**
    140146 * Native kernel thread wrapper function.
  • trunk/src/VBox/Runtime/r0drv/freebsd/thread2-r0drv-freebsd.c

    r19341 r34256  
    9999
    100100
     101void rtThreadNativeDestroy(PRTTHREADINT pThread)
     102{
     103    NOREF(pThread);
     104}
     105
     106
    101107/**
    102108 * Native thread main function.
  • trunk/src/VBox/Runtime/r0drv/nt/thread2-r0drv-nt.cpp

    r28800 r34256  
    8888
    8989
     90void rtThreadNativeDestroy(PRTTHREADINT pThread)
     91{
     92    NOREF(pThread);
     93}
     94
     95
    9096/**
    9197 * Native kernel thread wrapper function.
  • trunk/src/VBox/Runtime/r0drv/os2/thread2-r0drv-os2.cpp

    r8245 r34256  
    6666
    6767
     68void rtThreadNativeDestroy(PRTTHREADINT pThread)
     69{
     70    NOREF(pThread);
     71}
     72
     73
    6874int rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
    6975{
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/thread2-r0drv-solaris.c

    r28800 r34256  
    8181
    8282
     83void rtThreadNativeDestroy(PRTTHREADINT pThread)
     84{
     85    NOREF(pThread);
     86}
     87
     88
    8389/**
    8490 * Native thread main function.
  • trunk/src/VBox/Runtime/r3/os2/thread-os2.cpp

    r33393 r34256  
    9595
    9696
     97void rtThreadNativeDestroy(PRTTHREADINT pThread)
     98{
     99    if (pThread == *g_ppCurThread)
     100        *g_ppCurThread = NULL;
     101}
     102
     103
    97104/**
    98105 * Wrapper which unpacks the params and calls thread function.
  • trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp

    r34176 r34256  
    204204
    205205
     206void rtThreadNativeDestroy(PRTTHREADINT pThread)
     207{
     208    if (pThread == (PRTTHREADINT)pthread_getspecific(g_SelfKey))
     209        pthread_setspecific(g_SelfKey, NULL);
     210}
     211
     212
    206213/**
    207214 * Wrapper which unpacks the params and calls thread function.
     
    243250    rc = rtThreadMain(pThread, (uintptr_t)Self, &pThread->szName[0]);
    244251
    245     pthread_setspecific(g_SelfKey, NULL);
    246252    pthread_exit((void *)rc);
    247253    return (void *)rc;
  • trunk/src/VBox/Runtime/r3/win/thread-win.cpp

    r32914 r34256  
    7878        TlsSetValue(g_dwSelfTLS, NULL);
    7979    }
     80}
     81
     82
     83void rtThreadNativeDestroy(PRTTHREADINT pThread)
     84{
     85    if (pThread == (PRTTHREADINT)TlsGetValue(g_dwSelfTLS))
     86        TlsSetValue(g_dwSelfTLS, NULL);
    8087}
    8188
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