Ticket #6479 (new defect)

Bug contains 1 commit(s) | SVN Diffs for #6479

 

Opened 1 month ago

Last modified 1 month ago

ucol initialization thread safety question

Reported by: andy Assigned to: andy
Priority: major Milestone: 4.1.1
Component: collation Version: Current
Keywords: Cc:
Load: Xref:
Java Version: Operating System:
Project (C/J): ICU4C Weeks: .1
Review: markus

Description

Quetionable code in i18n/ucol_res.cpp, in the function ucol_initUCA(), near line 110:

    UBool needsInit;
    UMTX_CHECK(NULL, (_staticUCA == NULL), needsInit);

    if(needsInit) {
        UDataMemory *result = udata_openChoice(NULL, UCA_DATA_TYPE, UCA_DATA_NAME, isAcceptableUCA, NULL, status);

        if(U_SUCCESS(*status)){
            UCollator *newUCA = ucol_initCollator((const UCATableHeader *)udata_getMemory(result), NULL, NULL, status);
            if(U_SUCCESS(*status)){
                umtx_lock(NULL);
                if(_staticUCA == NULL) {
                    UCA_DATA_MEM = result;
                    _staticUCA = newUCA;
                    newUCA = NULL;
                    result = NULL;
                }
                umtx_unlock(NULL);

                ucln_i18n_registerCleanup(UCLN_I18N_UCOL_RES, ucol_res_cleanup);
                if(newUCA != NULL) {
                    ucol_close(newUCA);
                    udata_close(result);
                }
                // Initalize variables for implicit generation
                uprv_uca_initImplicitConstants(status);           <<<<<<<<<<<<<<<<<<<<

Is this thread safe? initImplicitConstants() happens outside the mutex, and after _staticUCA is set, meaning that other threads could see the initialization as having completed without initImplicitConstants() having run.

Attachments

Change History

08/05/08 16:37:14 changed by andy

  • project changed from all to ICU4C.
  • priority changed from assess to major.
  • milestone changed from 4.2 to 4.1.1.
  • owner changed from weiv to andy.
  • weeks set to .1.
  • revw set to markus.

Add/Change #6479 (ucol initialization thread safety question)




Anti spam check: