avoid self-locking in garbage collector.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2060 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2008-01-24 22:21:27 +00:00
parent 42c88eddff
commit 82508f287b
2 changed files with 25 additions and 6 deletions

View File

@ -2405,7 +2405,15 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
if (flags & IndexMask) {
LogUpdIndex *indx = ClauseFlagsToLogUpdIndex(pt0);
int erase;
LOCK(indx->ClPred->PELock);
#if defined(YAPOR) || defined(THREADS)
/*
gc may be called when executing a dynamic goal,
check PP to avoid deadlock
*/
PredEntry *ap = cl->ClPred;
if (ap != PP)
LOCK(ap->PELock);
#endif
DEC_CLREF_COUNT(indx);
indx->ClFlags &= ~InUseMask;
erase = (indx->ClFlags & ErasedMask
@ -2415,12 +2423,21 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
no one is accessing the clause */
Yap_ErLogUpdIndex(indx);
}
UNLOCK(indx->ClPred->PELock);
#if defined(YAPOR) || defined(THREADS)
if (ap != PP)
UNLOCK(ap->PELock);
#endif
} else {
LogUpdClause *cl = ClauseFlagsToLogUpdClause(pt0);
#if defined(YAPOR) || defined(THREADS)
PredEntry *ap = cl->ClPred;
#endif
int erase;
LOCK(cl->ClPred->PELock);
#if defined(YAPOR) || defined(THREADS)
if (ap != PP)
LOCK(ap->PELock);
#endif
DEC_CLREF_COUNT(cl);
cl->ClFlags &= ~InUseMask;
erase = ((cl->ClFlags & ErasedMask) && !cl->ClRefCount);
@ -2429,7 +2446,10 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
no one is accessing the clause */
Yap_ErLogUpdCl(cl);
}
UNLOCK(cl->ClPred->PELock);
#if defined(YAPOR) || defined(THREADS)
if (ap != PP)
UNLOCK(ap->PELock);
#endif
}
} else {
DynamicClause *cl = ClauseFlagsToDynamicClause(pt0);
@ -3867,8 +3887,6 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
/* expand the stack if effectiveness is less than 20 % */
if (ASP - H < gc_margin/sizeof(CELL) ||
effectiveness < 20) {
UInt sz;
LeaveGCMode();
return Yap_growstack(gc_margin);
}

View File

@ -17,6 +17,7 @@
<h2>Yap-5.1.3:</h2>
<ul>
<li> FIXED: do not access erased code (obs from Paulo Moura).</li>
<li> FIXED: clause/3 should not follow fail.</li>
<li> FIXED: make sure we don't ask for 0-sized blocks, minimal 64K.</li>
<li> FIXED: Aux reallocation should always increase aux size.</li>