From 8dd1ddbca32e29c44035cf46fd3adceeb200c3aa Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Thu, 20 Mar 2014 13:32:35 +0000 Subject: [PATCH] ensure things get locked when enterng dynamic code. --- C/absmi.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/C/absmi.c b/C/absmi.c index 3fba19721..f57440884 100755 --- a/C/absmi.c +++ b/C/absmi.c @@ -7967,25 +7967,6 @@ Yap_absmi(int inp) pt0 = Yap_ExpandIndex(pe, 0); /* restart index */ setregs(); - UNLOCKPE(17,pe); -#ifdef DEBUG_LOCK - { PredEntry *ap = pe; - if (ap->ArityOfPE) { - if ( ap->ModuleOfPred != IDB_MODULE) - printf("L9 %s\n", AtomName(NameOfFunctor(ap->FunctorOfPred))); - else - { - if (ap->PredFlags & NumberDBPredFlag) { - printf("L9 %ld\n", ap->src.IndxId); - } else if (ap->PredFlags & AtomDBPredFlag) { - printf("L9 %s\n", AtomName((Atom)(ap->FunctorOfPred))); - } else { - printf("L9 %s\n", AtomName(NameOfFunctor(ap->FunctorOfPred))); - } - } - } - } -#endif PREG = pt0; #if defined(YAPOR) || defined(THREADS) if (!PP) { @@ -8002,14 +7983,20 @@ Yap_absmi(int inp) PredEntry *pe = PredFromDefCode(PREG); BEGD(d0); /* avoid trouble with undefined dynamic procedures */ + /* I assume they were not locked beforehand */ +#if defined(YAPOR) || defined(THREADS) + if (!PP) + PELOCK(19,pe); +#endif if ((pe->PredFlags & (DynamicPredFlag|LogUpdatePredFlag|MultiFileFlag)) || (UndefCode->OpcodeOfPred == UNDEF_OPCODE)) { #if defined(YAPOR) || defined(THREADS) PP = NULL; -#endif UNLOCKPE(19,pe); +#endif FAIL(); } + UNLOCKPE(19,pe); d0 = pe->ArityOfPE; if (d0 == 0) { HR[1] = MkAtomTerm((Atom)(pe->FunctorOfPred));