Changeset: 78e44e24d4d6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=78e44e24d4d6
Modified Files:
gdk/gdk_atoms.c
gdk/gdk_bbp.c
monetdb5/mal/mal_atom.c
Branch: Jul2017
Log Message:
ATOMallocate should not call GDKfatal but return an error.
diffs (102 lines):
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -165,20 +165,25 @@ ATOMallocate(const char *id)
{
int t;
+ if (strlen(id) >= IDLENGTH) {
+ GDKerror("ATOMallocate: name too long");
+ return int_nil;
+ }
+
MT_lock_set(&GDKthreadLock);
t = ATOMindex(id);
-
if (t < 0) {
t = -t;
if (t == GDKatomcnt) {
+ if (GDKatomcnt == MAXATOMS) {
+ MT_lock_unset(&GDKthreadLock);
+ GDKerror("ATOMallocate: too many types");
+ return int_nil;
+ }
GDKatomcnt++;
}
- if (GDKatomcnt == MAXATOMS)
- GDKfatal("ATOMallocate: too many types");
- if (strlen(id) >= IDLENGTH)
- GDKfatal("ATOMallocate: name too long");
memset(BATatoms + t, 0, sizeof(atomDesc));
- snprintf(BATatoms[t].name, sizeof(BATatoms[t].name), "%s", id);
+ strcpy(BATatoms[t].name, id);
BATatoms[t].size = sizeof(int); /* default */
BATatoms[t].align = sizeof(int); /* default */
BATatoms[t].linear = 1; /* default */
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -284,7 +284,7 @@ BBPunlock(void)
}
-static void
+static gdk_return
BBPinithash(int j)
{
bat i = (bat) ATOMIC_GET(BBPsize, BBPsizeLock);
@@ -293,8 +293,10 @@ BBPinithash(int j)
for (BBP_mask = 1; (BBP_mask << 1) <= BBPlimit; BBP_mask <<= 1)
;
BBP_hash = (bat *) GDKzalloc(BBP_mask * sizeof(bat));
- if (BBP_hash == NULL)
- GDKfatal("BBPinithash: cannot allocate memory\n");
+ if (BBP_hash == NULL) {
+ GDKerror("BBPinithash: cannot allocate memory\n");
+ return GDK_FAIL;
+ }
BBP_mask--;
while (--i > 0) {
@@ -311,6 +313,7 @@ BBPinithash(int j)
j = 0;
}
}
+ return GDK_SUCCEED;
}
int
@@ -360,7 +363,8 @@ BBPextend(int idx, int buildhash)
BBP_hash = NULL;
for (i = 0; i <= BBP_THREADMASK; i++)
BBP_free(i) = 0;
- BBPinithash(idx);
+ if (BBPinithash(idx) != GDK_SUCCEED)
+ return GDK_FAIL;
}
return GDK_SUCCEED;
}
@@ -1402,7 +1406,8 @@ BBPinit(void)
BBPreadEntries(fp, bbpversion);
fclose(fp);
- BBPinithash(0);
+ if (BBPinithash(0) != GDK_SUCCEED)
+ GDKfatal("BBPinit: BBPinithash failed");
/* will call BBPrecover if needed */
if (BBPprepare(FALSE) != GDK_SUCCEED)
diff --git a/monetdb5/mal/mal_atom.c b/monetdb5/mal/mal_atom.c
--- a/monetdb5/mal/mal_atom.c
+++ b/monetdb5/mal/mal_atom.c
@@ -184,6 +184,10 @@ malAtomDefinition(stream *out, str name,
if (strlen(name) >= sizeof(BATatoms[0].name))
return -1;
i = ATOMallocate(name);
+ if (i == int_nil) {
+ showException(out, TYPE, "atomDefinition", "Could not allocate
atom '%s'", name);
+ return -1;
+ }
/* overload atom ? */
if (tpe) {
BATatoms[i] = BATatoms[tpe];
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list