IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28405 for trunk/psModules


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).

Location:
trunk/psModules/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmReadoutFake.c

    r26651 r28405  
    303303
    304304                if (!psThreadJobAddPending(job)) {
    305                     psFree(job);
    306305                    psFree(groups);
    307306                    return false;
    308307                }
    309                 psFree(job);
    310308            }
    311309            if (!psThreadPoolWait(true)) {
  • trunk/psModules/src/detrend/pmBias.c

    r21183 r28405  
    144144
    145145            if (!psThreadJobAddPending(job)) {
    146                 psFree(job);
    147146                return false;
    148147            }
    149             psFree(job);
    150148        } else if (!pmBiasSubtractScan(in, sub, scale, xOffset, yOffset, rowStart, rowStop)) {
    151149            psError(PS_ERR_UNKNOWN, false, "Unable to apply bias correction.");
  • trunk/psModules/src/detrend/pmDark.c

    r27597 r28405  
    587587
    588588            if (!psThreadJobAddPending (job)) {
    589                 psFree(job);
    590589                psFree(orders);
    591590                psFree(values);
    592591                return false;
    593592            }
    594             psFree(job);
    595593        } else if (!pmDarkApplyScan(readout, dark, orders, values, bad, doNorm, norm, rowStart, rowStop)) {
    596594            psError(PS_ERR_UNKNOWN, false, "Unable to apply dark.");
  • trunk/psModules/src/detrend/pmFlatField.c

    r21533 r28405  
    150150
    151151          if (!psThreadJobAddPending(job)) {
    152               psFree(job);
    153152              return false;
    154153          }
    155           psFree(job);
    156154      } else if (!pmFlatFieldScan(inImage, inMask, inVar, flatImage, flatMask, badFlat,
    157155                                  xOffset, yOffset, rowStart, rowStop)) {
  • 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);
  • trunk/psModules/src/imcombine/pmStackReject.c

    r27365 r28405  
    289289                    PS_ARRAY_ADD_SCALAR(args, poorFrac, PS_TYPE_F32);
    290290                    if (!psThreadJobAddPending(job)) {
    291                         psFree(job);
    292291                        psFree(source);
    293292                        psFree(target);
    294293                        return NULL;
    295294                    }
    296                     psFree(job);
    297295                } else if (!stackRejectGrow(target, source, kernels, numCols, numRows,
    298296                                            i, xSubMax, j, ySubMax, poorFrac)) {
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r28150 r28405  
    12911291
    12921292                if (!psThreadJobAddPending(job)) {
    1293                     psFree(job);
    12941293                    return false;
    12951294                }
    1296                 psFree(job);
    12971295            } else {
    12981296                subtractionConvolvePatch(numCols, numRows, x0, y0, out1, out2, convMask, ro1, ro2,
  • trunk/psModules/src/imcombine/pmSubtractionEquation.c

    r27335 r28405  
    860860            PS_ARRAY_ADD_SCALAR(job->args, mode, PS_TYPE_S32);
    861861            if (!psThreadJobAddPending(job)) {
    862                 psFree(job);
    863862                return false;
    864863            }
    865             psFree(job);
    866864        } else {
    867865            pmSubtractionCalculateEquationStamp(stamps, kernels, i, mode);
  • trunk/psModules/src/imcombine/pmSubtractionMatch.c

    r27365 r28405  
    10601060            PS_ARRAY_ADD_SCALAR(job->args, bg2, PS_TYPE_F32);
    10611061            if (!psThreadJobAddPending(job)) {
    1062                 psFree(job);
    10631062                return false;
    10641063            }
    1065             psFree(job);
    10661064        } else {
    10671065            if (!pmSubtractionOrderStamp(ratios, mask, stamps, models, modelSums, i, bg1, bg2)) {
Note: See TracChangeset for help on using the changeset viewer.