we cannot trust that just having on reference will protect a clause. Several references may go in a single operation!
This commit is contained in:
parent
d78a55ca83
commit
c8ef4dbdb4
@ -1131,8 +1131,9 @@ Yap_absmi(int inp)
|
|||||||
/* next, recover space for the indexing code if it was erased */
|
/* next, recover space for the indexing code if it was erased */
|
||||||
if (cl->ClFlags & (ErasedMask|DirtyMask)) {
|
if (cl->ClFlags & (ErasedMask|DirtyMask)) {
|
||||||
if (PREG != FAILCODE) {
|
if (PREG != FAILCODE) {
|
||||||
/* make sure we don't erase the clause we are jumping too */
|
/* make sure we don't erase the clause we are jumping to,
|
||||||
if (lcl->ClRefCount == 1 && !(lcl->ClFlags & InUseMask)) {
|
notice that we can erase a number of refs in one go. */
|
||||||
|
if (!(lcl->ClFlags & InUseMask)) {
|
||||||
lcl->ClFlags |= InUseMask;
|
lcl->ClFlags |= InUseMask;
|
||||||
TRAIL_CLREF(lcl);
|
TRAIL_CLREF(lcl);
|
||||||
}
|
}
|
||||||
@ -1439,7 +1440,7 @@ Yap_absmi(int inp)
|
|||||||
if (cl->ClFlags & (ErasedMask|DirtyMask)) {
|
if (cl->ClFlags & (ErasedMask|DirtyMask)) {
|
||||||
if (PREG != FAILCODE) {
|
if (PREG != FAILCODE) {
|
||||||
/* make sure we don't erase the clause we are jumping too */
|
/* make sure we don't erase the clause we are jumping too */
|
||||||
if (lcl->ClRefCount == 1 && !(lcl->ClFlags & InUseMask)) {
|
if (!(lcl->ClFlags & InUseMask)) {
|
||||||
lcl->ClFlags |= InUseMask;
|
lcl->ClFlags |= InUseMask;
|
||||||
TRAIL_CLREF(lcl);
|
TRAIL_CLREF(lcl);
|
||||||
}
|
}
|
||||||
@ -8066,7 +8067,7 @@ Yap_absmi(int inp)
|
|||||||
if (cl->ClFlags & (ErasedMask|DirtyMask)) {
|
if (cl->ClFlags & (ErasedMask|DirtyMask)) {
|
||||||
if (PREG != FAILCODE) {
|
if (PREG != FAILCODE) {
|
||||||
/* make sure we don't erase the clause we are jumping too */
|
/* make sure we don't erase the clause we are jumping too */
|
||||||
if (lcl->ClRefCount == 1 && !(lcl->ClFlags & InUseMask)) {
|
if (!(lcl->ClFlags & InUseMask)) {
|
||||||
lcl->ClFlags |= InUseMask;
|
lcl->ClFlags |= InUseMask;
|
||||||
TRAIL_CLREF(lcl);
|
TRAIL_CLREF(lcl);
|
||||||
B->cp_tr = TR;
|
B->cp_tr = TR;
|
||||||
|
21
C/index.c
21
C/index.c
@ -6305,14 +6305,28 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
|||||||
DEC_CLREF_COUNT(cl);
|
DEC_CLREF_COUNT(cl);
|
||||||
/* actually get rid of the code */
|
/* actually get rid of the code */
|
||||||
if (cl->ClRefCount == 0 && cl->ClFlags & (ErasedMask|DirtyMask)) {
|
if (cl->ClRefCount == 0 && cl->ClFlags & (ErasedMask|DirtyMask)) {
|
||||||
|
/* I am the last one using this clause, hence I don't need a lock
|
||||||
|
to dispose of it. But on the other hand I need to make sure
|
||||||
|
the clause is still there when I am back.
|
||||||
|
*/
|
||||||
|
LogUpdClause *lcl = ipc->u.OtILl.d;
|
||||||
|
if (newpc) {
|
||||||
/* I am the last one using this clause, hence I don't need a lock
|
/* I am the last one using this clause, hence I don't need a lock
|
||||||
to dispose of it
|
to dispose of it
|
||||||
*/
|
*/
|
||||||
|
/* make sure the clause isn't destroyed */
|
||||||
|
/* always add an extra reference */
|
||||||
|
INC_CLREF_COUNT(lcl);
|
||||||
|
TRAIL_CLREF(lcl);
|
||||||
|
}
|
||||||
if (cl->ClFlags & ErasedMask) {
|
if (cl->ClFlags & ErasedMask) {
|
||||||
Yap_ErLogUpdIndex(cl);
|
Yap_ErLogUpdIndex(cl);
|
||||||
} else {
|
} else {
|
||||||
Yap_CleanUpIndex(cl);
|
Yap_CleanUpIndex(cl);
|
||||||
}
|
}
|
||||||
|
if (newpc) {
|
||||||
|
DEC_CLREF_COUNT(lcl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (TrailTerm(B->cp_tr-1) == CLREF_TO_TRENTRY(cl) &&
|
if (TrailTerm(B->cp_tr-1) == CLREF_TO_TRENTRY(cl) &&
|
||||||
@ -6324,8 +6338,11 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
|||||||
/* next, recover space for the indexing code if it was erased */
|
/* next, recover space for the indexing code if it was erased */
|
||||||
if (cl->ClFlags & (ErasedMask|DirtyMask)) {
|
if (cl->ClFlags & (ErasedMask|DirtyMask)) {
|
||||||
LogUpdClause *lcl = ipc->u.OtILl.d;
|
LogUpdClause *lcl = ipc->u.OtILl.d;
|
||||||
/* make sure we don't erase the clause we are jumping to */
|
/* make sure we don't erase the clause we are jumping to, notice that
|
||||||
if (lcl->ClRefCount == 1 && !(lcl->ClFlags & (DirtyMask|InUseMask))) {
|
ErLogUpdIndex may remove several references in one go.
|
||||||
|
Notice we only need to do this if we´ re jumping to the clause.
|
||||||
|
*/
|
||||||
|
if (newpc && !(lcl->ClFlags & (DirtyMask|InUseMask))) {
|
||||||
lcl->ClFlags |= InUseMask;
|
lcl->ClFlags |= InUseMask;
|
||||||
TRAIL_CLREF(lcl);
|
TRAIL_CLREF(lcl);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user