fix heap overflow in YAP_LookupAtom

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1098 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-07-23 03:37:17 +00:00
parent d16b7e4ec9
commit 3e0a3fa9f3
5 changed files with 400 additions and 168 deletions

View File

@ -10,8 +10,14 @@
* File: c_interface.c *
* comments: c_interface primitives definition *
* *
* Last rev: $Date: 2004-07-22 21:32:20 $,$Author: vsc $ *
* Last rev: $Date: 2004-07-23 03:37:16 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.51 2004/07/22 21:32:20 vsc
* debugger fixes
* initial support for JPL
* bad calls to garbage collector and gc
* debugger fixes
*
* Revision 1.50 2004/06/29 19:04:41 vsc
* fix multithreaded version
* include new version of Ricardo's profiler
@ -340,7 +346,13 @@ YAP_AtomName(Atom a)
X_API Atom
YAP_LookupAtom(char *c)
{
return(Yap_LookupAtom(c));
Atom a = Yap_LookupAtom(c);
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
}
}
return a;
}
X_API Atom
@ -349,6 +361,11 @@ YAP_FullLookupAtom(char *c)
Atom at;
at = Yap_FullLookupAtom(c);
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
}
}
return(at);
}
@ -947,6 +964,11 @@ YAP_CompileClause(Term t)
}
YAPLeaveCriticalSection();
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
}
}
RECOVER_MACHINE_REGS();
return(Yap_ErrorMessage);
}

View File

@ -111,7 +111,9 @@ HEADERS = \
$(srcdir)/H/corout.h $(srcdir)/H/eval.h $(srcdir)/H/heapgc.h \
$(srcdir)/H/index.h $(srcdir)/H/iopreds.h \
$(srcdir)/H/rheap.h \
$(srcdir)/H/tracer.h $(srcdir)/H/yapio.h \
$(srcdir)/H/tracer.h \
$(srcdir)/H/threads.h \
$(srcdir)/H/yapio.h \
$(srcdir)/OPTYap/opt.config.h \
$(srcdir)/OPTYap/opt.proto.h $(srcdir)/OPTYap/opt.structs.h \
$(srcdir)/OPTYap/opt.macros.h $(srcdir)/OPTYap/or.macros.h \
@ -512,6 +514,7 @@ install_unix: startup
@INSTALL_DLLS@ (cd library/system; make install)
@INSTALL_DLLS@ (cd library/yap2swi; make install)
@INSTALL_DLLS@ (cd library/Tries; make install)
@ENABLE_JAVA@ @INSTALL_DLLS@ (cd LGPL/JPL_from_Prolog/src; make install)
mkdir -p $(DESTDIR)$(INCLUDEDIR)
for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done
@ -540,10 +543,12 @@ install_library: @YAPLIB@
install_data:
(cd library ; make install)
@ENABLE_JAVA@ (cd LGPL/JPL_from_Prolog ; make install)
$(INSTALL_DATA) $(srcdir)/LGPL/pillow/icon_address.pl $(DESTDIR)$(SHAREDIR)/Yap/
$(INSTALL_DATA) $(srcdir)/LGPL/pillow/pillow.pl $(DESTDIR)$(SHAREDIR)/Yap/
(cd CLPQR ; make install)
(cd CHR ; make install)
(cd CLPBN ; make install)
##########

469
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -82,6 +82,21 @@ AC_ARG_WITH(gmp,
fi,
[yap_cv_gmp=yes])
AC_ARG_WITH(java,
[ --with-java=JAVA_HOME use Java instalation in JAVA_HOME],
if test "$withval" = yes; then
yap_cv_java="$JAVA_HOME"
dynamic_loading=yes
threads=yes
elif test "$withval" = no; then
yap_cv_java=no
else
yap_cv_java=$with_java
dynamic_loading=yes
threads=yes
fi,
[yap_cv_java=no])
AC_ARG_WITH(readline,
[ --with-readline[=DIR] use GNU Readline Library in DIR],
if test "$withval" = yes; then
@ -348,6 +363,14 @@ then
fi
fi
if test "$yap_cv_java" = no
then
ENABLE_JAVA="@#"
else
ENABLE_JAVA=""
JAVA_HOME="$yap_cv_java"
fi
MPI_OBJS=
if test "$yap_cv_mpi" != "no"
then
@ -432,6 +455,8 @@ AC_SUBST(INSTALL_INFO)
dnl let YAP_EXTRAS fall through configure, from the env into Makefile
AC_SUBST(YAP_EXTRAS)
AC_SUBST(NO_BUILTIN_REGEXP)
AC_SUBST(ENABLE_JAVA)
AC_SUBST(JAVA_HOME)
dnl defaults
INSTALL_DLLS="#"
@ -440,14 +465,6 @@ DO_SECOND_LD="#"
M4="m4"
MERGE_DLL_OBJS="#"
if test "$dynamic_loading" = "yes"
then
YAP_EXTRAS="$SHLIB_CFLAGS $YAP_EXTRAS"
YAPLIB=libYap"$SHLIB_SUFFIX"
else
YAPLIB="libYap.a"
fi
case "$target_os" in
*linux*)
if test "$use_condor" = "no"
@ -625,6 +642,14 @@ dnl Linux has both elf and a.out, in this case we found elf
;;
esac
if test "$dynamic_loading" = "yes"
then
YAP_EXTRAS="$SHLIB_CFLAGS $YAP_EXTRAS"
YAPLIB=libYap"$SHLIB_SUFFIX"
else
YAPLIB="libYap.a"
fi
if test "$coroutining" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DCOROUTINING=1"
@ -1037,8 +1062,12 @@ mkdir -p library/Tries
mkdir -p library/yap2swi
mkdir -p CHR
mkdir -p CLPQR
mkdir -p CLPBN
mkdir -p LGPL
mkdir -p LGPL/JPL_from_Prolog
mkdir -p LGPL/JPL_from_Prolog/src
AC_OUTPUT(Makefile library/regex/Makefile library/system/Makefile library/random/Makefile library/yap2swi/Makefile library/mpi/Makefile .depend library/Makefile CHR/Makefile CLPQR/Makefile library/Tries/Makefile)
AC_OUTPUT(Makefile library/regex/Makefile library/system/Makefile library/random/Makefile library/yap2swi/Makefile library/mpi/Makefile .depend library/Makefile CHR/Makefile CLPBN/Makefile CLPQR/Makefile library/Tries/Makefile LGPL/JPL_from_Prolog/Makefile LGPL/JPL_from_Prolog/src/Makefile)
make depend

View File

@ -8,8 +8,11 @@
* *
**************************************************************************
* *
* $Id: sys.c,v 1.18 2004-01-26 12:51:33 vsc Exp $ *
* $Id: sys.c,v 1.19 2004-07-23 03:37:17 vsc Exp $ *
* mods: $Log: not supported by cvs2svn $
* mods: Revision 1.18 2004/01/26 12:51:33 vsc
* mods: should be datime/1 not date/1
* mods:
* mods: Revision 1.17 2004/01/26 12:41:06 vsc
* mods: bug fixes
* mods:
@ -141,6 +144,7 @@ static int
list_directory(void)
{
YAP_Term tf = YAP_MkAtomTerm(YAP_LookupAtom("[]"));
long sl = YAP_InitSlot(tf);
char *buf = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1));
#if defined(__MINGW32__) || _MSC_VER
@ -162,14 +166,13 @@ list_directory(void)
if ((hFile = _findfirst(bs, &c_file)) == -1L) {
return(YAP_Unify(YAP_ARG2,tf));
}
tf = YAP_MkPairTerm(YAP_MkAtomTerm(YAP_LookupAtom(c_file.name)), tf);
YAP_PutInSlot(sl, YAP_MkPairTerm(YAP_MkAtomTerm(YAP_LookupAtom(c_file.name)), YAP_GetFromSlot(sl)));
while (_findnext( hFile, &c_file) == 0) {
YAP_Term ti = YAP_MkAtomTerm(YAP_LookupAtom(c_file.name));
tf = YAP_MkPairTerm(ti, tf);
YAP_PutInSlot(sl,YAP_MkPairTerm(ti, YAP_GetFromSlot(sl)));
}
_findclose( hFile );
#else
#if HAVE_OPENDIR
#elif HAVE_OPENDIR
{
DIR *de;
struct dirent *dp;
@ -179,13 +182,13 @@ list_directory(void)
}
while ((dp = readdir(de))) {
YAP_Term ti = YAP_MkAtomTerm(YAP_LookupAtom(dp->d_name));
tf = YAP_MkPairTerm(ti, tf);
YAP_PutInSlot(sl,YAP_MkPairTerm(ti, YAP_GetFromSlot(sl)));
}
closedir(de);
}
#endif /* HAVE_OPENDIR */
#endif
return(YAP_Unify(YAP_ARG2, tf));
tf = YAP_GetFromSlot(sl);
return YAP_Unify(YAP_ARG2, tf);
}
static int