VirtualBox

Changeset 92145 in vbox for trunk/src/VBox/Main/src-all


Ignore:
Timestamp:
Oct 29, 2021 1:00:02 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147966
Message:

Main/VirtualBoxTranslator.cpp: Write lock the object in the destructor to try prevent destroying it while someone is changing the language (com::Shutdown / notification race). Introduced some logging. bugref:1909

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/VirtualBoxTranslator.cpp

    r92115 r92145  
    1616 */
    1717
     18
     19/*********************************************************************************************************************************
     20*   Header Files                                                                                                                 *
     21*********************************************************************************************************************************/
     22#define LOG_GROUP LOG_GROUP_MAIN_VIRTUALBOXCLIENT /** @todo add separate logging group! */
     23#include "LoggingNew.h"
     24
    1825#include <iprt/asm.h>
    1926#include <iprt/ctype.h>
     
    3138#include "VirtualBoxTranslator.h"
    3239
     40
     41/*********************************************************************************************************************************
     42*   Defined Constants And Macros                                                                                                 *
     43*********************************************************************************************************************************/
    3344#define TRANSLATOR_CACHE_SIZE 32
    3445
     46
     47/*********************************************************************************************************************************
     48*   Global Variables                                                                                                             *
     49*********************************************************************************************************************************/
    3550/** Init once for the critical section. */
    3651static RTONCE               g_Once = RTONCE_INITIALIZER;
     
    4257static RTTLS                g_idxTlsSrc = NIL_RTTLS;
    4358
     59
     60
    4461/**
    4562 * @callback_method_impl{FNRTONCE}
     
    6582    if (RT_FAILURE(rc))
    6683        m_hStrCache = NIL_RTSTRCACHE; /* (loadLanguage will fail) */
     84    LogFlowFunc(("m_rcCache=%Rrc g_idxTlsTr=%#x g_idxTlsSrc=%#x\n", m_rcCache, g_idxTlsTr, g_idxTlsSrc));
    6785}
    6886
     
    7088VirtualBoxTranslator::~VirtualBoxTranslator()
    7189{
     90    LogFlowFunc(("enter\n"));
     91
     92    /* Write-lock the object as we could be racing language change
     93       notifications processing during XPCOM shutdown. (risky?) */
     94    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     95
    7296    RTTlsFree(g_idxTlsTr);
    7397    g_idxTlsTr = NIL_RTTLS;
     
    91115        m_rcCache = VERR_WRONG_ORDER;
    92116    }
     117    LogFlowFunc(("returns\n"));
    93118}
    94119
     
    203228int VirtualBoxTranslator::i_loadLanguage(const char *pszLang)
    204229{
     230    LogFlowFunc(("pszLang=%s\n", pszLang));
    205231    int  rc = VINF_SUCCESS;
    206232    char szLocale[256];
     
    241267{
    242268    AssertReturn(aComponent, VERR_INVALID_PARAMETER);
     269    LogFlow(("aComponent=%s aLang=%s\n", aComponent->strPath.c_str(), aLang));
     270
    243271    int rc;
    244272    if (strcmp(aLang, "C") != 0)
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