IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 18, 2010, 2:25:38 PM (16 years ago)
Author:
Paul Price
Message:

Discovered a race condition in the threading process. The thread process was: psThreadJobAlloc, populate job with arguments, psThreadJobAddPending, psFree the job. This is not thread-safe, because we're decrementing the job's reference counter while the reference count is also being fiddled within the thread system (psThread.c; by pulling the job off the 'pending' queue and putting it on the 'done' queue). The reference count fiddling within the thread system was protected by a mutex, but the external free was not. Therefore, I'm pulling the free into the thread system so it can be protected (without the user having to worry about locks to do the simple case). This means that the user should no longer touch the job once he hands it over to the thread system (unless it's protected by calls to psThreadLock/psThreadUnlock, or it's on the other side of psThreadPoolWait from all the adds so that the threads aren't doing anything).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmShutterCorrection.c

    r27832 r28405  
    351351    psStats *resStats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
    352352    if (!psVectorStats (rawStats, counts, NULL, NULL, 0)) {
    353         psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
    354         return NULL;
     353        psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     354        return NULL;
    355355    }
    356356    if (!psVectorStats (resStats, resid, NULL, NULL, 0)) {
    357         psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
    358         return NULL;
     357        psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     358        return NULL;
    359359    }
    360360
     
    794794
    795795                if (!psThreadJobAddPending(job)) {
    796                     psFree(job);
    797796                    return false;
    798797                }
    799                 psFree(job);
    800798            } else if (!pmShutterCorrectionApplyScan(image, mask, var, shutterImage, exptime, blank,
    801799                                                     rowStart, rowStop)) {
     
    10171015
    10181016        if (corr) {
    1019             psTrace("psModules.detrend", 5, "Shutter correction fit: scale: %f, offset: %f, offref: %f\n", corr->scale, corr->offset, corr->offref);
    1020             if (isfinite(corr->offref) && corr->valid) {
    1021                 psTrace("psModules.detrend", 5, "Sample reference value: %f\n", corr->offref);
    1022                 meanRef += corr->offref;
    1023                 numGood++;
    1024             }
     1017            psTrace("psModules.detrend", 5, "Shutter correction fit: scale: %f, offset: %f, offref: %f\n", corr->scale, corr->offset, corr->offref);
     1018            if (isfinite(corr->offref) && corr->valid) {
     1019                psTrace("psModules.detrend", 5, "Sample reference value: %f\n", corr->offref);
     1020                meanRef += corr->offref;
     1021                numGood++;
     1022            }
    10251023        } else {
    1026             psTrace("psModules.detrend", 5, "failed Shutter correction fit\n");
    1027         }
     1024            psTrace("psModules.detrend", 5, "failed Shutter correction fit\n");
     1025        }
    10281026
    10291027        psFree(corr);
Note: See TracChangeset for help on using the changeset viewer.