IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19449


Ignore:
Timestamp:
Sep 9, 2008, 4:48:32 PM (18 years ago)
Author:
Paul Price
Message:

I think the memory corruption in subMask when running threaded is due
to using psThreadPoolWait to harvest the jobs. I don't think we can
rely on psThreadPoolWait to harvest the jobs because the job contains
a reference to the subMask, which is being changed on a thread, and
psThreadPoolWait doesn't know that it needs to be locked before
freeing. After psThreadPoolWait, however, the jobs are completed, the
threads are idle, and so there's no need to lock the subMask when
we're blowing away the jobs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_080908/psModules/src/imcombine/pmSubtraction.c

    r19357 r19449  
    11411141                    psMutexLock(subMask);
    11421142                }
    1143                 psArrayAdd(args, 1, (psImage*)subMask); // Casting away const
     1143                psArrayAdd(args, 1, subMask);
    11441144                if (subMask) {
    11451145                    psMutexUnlock(subMask);
     
    11661166    }
    11671167
    1168     if (!psThreadPoolWait(true)) {
     1168    if (!psThreadPoolWait(false)) {
    11691169        psError(PS_ERR_UNKNOWN, false, "Error waiting for threads.");
    11701170        return false;
    11711171    }
    11721172
    1173     if (subMask && threaded) {
    1174         psMutexDestroy(subMask);
     1173    // We don't rely on psThreadPoolWait to harvest the jobs because the job contains a reference to the
     1174    // subMask, which is being changed on a thread, and psThreadPoolWait doesn't know that it needs to be
     1175    // locked before freeing.  After psThreadPoolWait, however, the jobs are completed, the threads are idle,
     1176    // and so there's no need to lock the subMask when we're blowing away the jobs.
     1177    if (threaded) {
     1178        psThreadJob *job;               // Completed job
     1179        while ((job = psThreadJobGetDone())) {
     1180            psFree(job);
     1181        }
     1182
     1183        if (subMask) {
     1184            psMutexDestroy(subMask);
     1185        }
    11751186    }
    11761187
Note: See TracChangeset for help on using the changeset viewer.