fix bug in handling Yap heap overflow while adding new clause.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1169 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-10-31 02:18:04 +00:00
parent 2dfdca263d
commit 33207cac91
3 changed files with 26 additions and 10 deletions

View File

@ -10,8 +10,15 @@
* File: c_interface.c * * File: c_interface.c *
* comments: c_interface primitives definition * * comments: c_interface primitives definition *
* * * *
* Last rev: $Date: 2004-10-28 20:12:20 $,$Author: vsc $ * * Last rev: $Date: 2004-10-31 02:18:03 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.55 2004/10/28 20:12:20 vsc
* Use Doug Lea's malloc as an alternative to YAP's standard malloc
* don't use TR directly in scanner/parser, this avoids trouble with ^C while
* consulting large files.
* pass gcc -mno-cygwin to library compilation in cygwin environment (cygwin should
* compile out of the box now).
*
* Revision 1.54 2004/10/06 16:55:46 vsc * Revision 1.54 2004/10/06 16:55:46 vsc
* change configure to support big mem configs * change configure to support big mem configs
* get rid of extra globals * get rid of extra globals
@ -968,6 +975,7 @@ YAP_CompileClause(Term t)
{ {
yamop *codeaddr; yamop *codeaddr;
int mod = CurrentModule; int mod = CurrentModule;
Term tn = TermNil
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
@ -977,7 +985,7 @@ YAP_CompileClause(Term t)
codeaddr = Yap_cclause (t,0, mod, t); codeaddr = Yap_cclause (t,0, mod, t);
if (codeaddr != NULL) { if (codeaddr != NULL) {
t = Deref(ARG1); /* just in case there was an heap overflow */ t = Deref(ARG1); /* just in case there was an heap overflow */
Yap_addclause (t, codeaddr, TRUE, mod, TermNil); Yap_addclause (t, codeaddr, TRUE, mod, &tn);
} }
YAPLeaveCriticalSection(); YAPLeaveCriticalSection();

View File

@ -11,8 +11,15 @@
* File: cdmgr.c * * File: cdmgr.c *
* comments: Code manager * * comments: Code manager *
* * * *
* Last rev: $Date: 2004-10-28 20:12:21 $,$Author: vsc $ * * Last rev: $Date: 2004-10-31 02:18:03 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.139 2004/10/28 20:12:21 vsc
* Use Doug Lea's malloc as an alternative to YAP's standard malloc
* don't use TR directly in scanner/parser, this avoids trouble with ^C while
* consulting large files.
* pass gcc -mno-cygwin to library compilation in cygwin environment (cygwin should
* compile out of the box now).
*
* Revision 1.138 2004/10/26 20:15:51 vsc * Revision 1.138 2004/10/26 20:15:51 vsc
* More bug fixes for overflow handling * More bug fixes for overflow handling
* *
@ -1482,7 +1489,7 @@ is_fact(Term t)
} }
static int static int
addclause(Term t, yamop *cp, int mode, Term mod, Term t4ref) addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
/* /*
* *
mode mode
@ -1608,8 +1615,8 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term t4ref)
} else { } else {
tf = Yap_MkStaticRefTerm((StaticClause *)cp); tf = Yap_MkStaticRefTerm((StaticClause *)cp);
} }
if (t4ref != TermNil) { if (*t4ref != TermNil) {
if (!Yap_unify(t4ref,tf)) { if (!Yap_unify(*t4ref,tf)) {
return FALSE; return FALSE;
} }
} }
@ -1628,7 +1635,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term t4ref)
} }
int int
Yap_addclause(Term t, yamop *cp, int mode, Term mod, Term t4ref) { Yap_addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref) {
return addclause(t, cp, mode, mod, t4ref); return addclause(t, cp, mode, mod, t4ref);
} }
@ -1875,6 +1882,7 @@ p_compile(void)
Term t = Deref(ARG1); Term t = Deref(ARG1);
Term t1 = Deref(ARG2); Term t1 = Deref(ARG2);
Term mod = Deref(ARG4); Term mod = Deref(ARG4);
Term tn = TermNil;
yamop *codeadr; yamop *codeadr;
if (IsVarTerm(t1) || !IsIntTerm(t1)) if (IsVarTerm(t1) || !IsIntTerm(t1))
@ -1887,7 +1895,7 @@ p_compile(void)
to cclause in case there is overflow */ to cclause in case there is overflow */
t = Deref(ARG1); /* just in case there was an heap overflow */ t = Deref(ARG1); /* just in case there was an heap overflow */
if (!Yap_ErrorMessage) if (!Yap_ErrorMessage)
addclause(t, codeadr, (int) (IntOfTerm(t1) & 3), mod, TermNil); addclause(t, codeadr, (int) (IntOfTerm(t1) & 3), mod, &tn);
YAPLeaveCriticalSection(); YAPLeaveCriticalSection();
if (Yap_ErrorMessage) { if (Yap_ErrorMessage) {
if (IntOfTerm(t1) & 4) { if (IntOfTerm(t1) & 4) {
@ -1922,7 +1930,7 @@ p_compile_dynamic(void)
if (!Yap_ErrorMessage) { if (!Yap_ErrorMessage) {
optimizer_on = old_optimize; optimizer_on = old_optimize;
addclause(t, code_adr, (int) (IntOfTerm(t1) & 3), mod, ARG5); addclause(t, code_adr, (int) (IntOfTerm(t1) & 3), mod, &ARG5);
} }
if (Yap_ErrorMessage) { if (Yap_ErrorMessage) {
if (IntOfTerm(t1) & 4) { if (IntOfTerm(t1) & 4) {

View File

@ -185,7 +185,7 @@ void STD_PROTO(Yap_InitComma,(void));
/* cdmgr.c */ /* cdmgr.c */
void STD_PROTO(Yap_IPred,(PredEntry *, UInt)); void STD_PROTO(Yap_IPred,(PredEntry *, UInt));
int STD_PROTO(Yap_addclause,(Term,yamop *,int,Term,Term)); int STD_PROTO(Yap_addclause,(Term,yamop *,int,Term,Term*));
void STD_PROTO(Yap_add_logupd_clause,(PredEntry *,LogUpdClause *,int)); void STD_PROTO(Yap_add_logupd_clause,(PredEntry *,LogUpdClause *,int));
void STD_PROTO(Yap_kill_iblock,(ClauseUnion *,ClauseUnion *,PredEntry *)); void STD_PROTO(Yap_kill_iblock,(ClauseUnion *,ClauseUnion *,PredEntry *));
void STD_PROTO(Yap_cleanup_dangling_indices,(yamop *,yamop *,yamop *,yamop *)); void STD_PROTO(Yap_cleanup_dangling_indices,(yamop *,yamop *,yamop *,yamop *));