VirtualBox

Changeset 32832 in vbox


Ignore:
Timestamp:
Sep 29, 2010 9:11:30 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
66291
Message:

Additions/x11/VBoxClient: attempt to fix segfault on shutdown

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/main.cpp

    r28800 r32832  
    2727#include <X11/Xlib.h>
    2828
     29#include <iprt/critsect.h>
    2930#include <iprt/env.h>
    3031#include <iprt/initterm.h>
     
    5152 * cleanup routine. */
    5253static RTFILE g_hPidFile;
     54/** Global critical section used to protect the clean-up routine, which can be
     55 * called from different threads.
     56 */
     57RTCRITSECT g_critSect;
    5358
    5459/** Clean up if we get a signal or something.  This is extern so that we
     
    5661void VBoxClient::CleanUp()
    5762{
     63    /* We never release this, as we end up with a call to exit(3) which is not
     64     * async-safe.  Until we fix this application properly, we should be sure
     65     * never to exit from anywhere except from this method. */
     66    int rc = RTCritSectEnter(&g_critSect);
     67    if (RT_FAILURE(rc))
     68    {
     69        RTPrintf("VBoxClient: Failure while acquiring the global critical section, rc=%Rrc\n", rc);
     70        _Exit(1);
     71    }
    5872    if (g_pService)
    5973    {
     
    149163int main(int argc, char *argv[])
    150164{
    151     int rcClipboard, rc = VINF_SUCCESS;
     165    int rcClipboard, rc;
    152166    const char *pszFileName = RTPathFilename(argv[0]);
    153167    bool fDaemonise = true;
     
    161175
    162176    /* Initialise our runtime before all else. */
    163     RTR3Init();
     177    rc = RTR3Init();
     178    if (RT_FAILURE(rc))
     179    {
     180        /* Of course, this should never happen. */
     181        RTPrintf("%s: Failed to initialise the run-time library, rc=%Rrc\n", pszFileName, rc);
     182        exit(1);
     183    }
     184
     185    /* Initialise our global clean-up critical section */
     186    rc = RTCritSectInit(&g_critSect);
     187    if (RT_FAILURE(rc))
     188    {
     189        /* Of course, this should never happen. */
     190        RTPrintf("%s: Failed to initialise the global critical section, rc=%Rrc\n", pszFileName, rc);
     191        exit(1);
     192    }
    164193
    165194    /* Parse our option(s) */
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