Changeset: 0b0a45cdb935 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0b0a45cdb935
Modified Files:
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_module.c
monetdb5/mal/mal_stack.c
monetdb5/modules/mal/tablet.c
monetdb5/modules/mal/txtsim.c
Branch: default
Log Message:
Defense lines for GDKmalloc failures
diffs (104 lines):
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -249,13 +249,13 @@ copyMalBlk(MalBlkPtr old)
mb->keephistory = old->keephistory;
mb->var = (VarRecord *) GDKzalloc(sizeof(VarRecord) * old->vsize);
- mb->activeClients = 1;
-
if (mb->var == NULL) {
GDKfree(mb);
GDKerror("copyMalBlk:" MAL_MALLOC_FAIL);
return NULL;
}
+
+ mb->activeClients = 1;
mb->vsize = old->vsize;
mb->vtop = old->vtop;
mb->vid = old->vid;
diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c
--- a/monetdb5/mal/mal_module.c
+++ b/monetdb5/mal/mal_module.c
@@ -31,6 +31,8 @@ Module moduleIndex[MODULE_HASH_SIZE] = {
static void newModuleSpace(Module scope){
scope->space = (Symbol *) GDKzalloc(MAXSCOPE * sizeof(Symbol));
+ if( scope->space == 0)
+ GDKerror("newModuleSpace:"MAL_MALLOC_FAIL);
}
void
diff --git a/monetdb5/mal/mal_stack.c b/monetdb5/mal/mal_stack.c
--- a/monetdb5/mal/mal_stack.c
+++ b/monetdb5/mal/mal_stack.c
@@ -50,6 +50,7 @@
*/
#include "monetdb_config.h"
#include "mal_stack.h"
+#include "mal_exception.h"
/* #define DEBUG_MAL_STACK*/
@@ -60,6 +61,7 @@ newGlobalStack(int size)
s = (MalStkPtr) GDKzalloc(stackSize(size) + offsetof(MalStack, stk));
if (!s) {
+ GDKerror("newGlobalStack:"MAL_MALLOC_FAIL);
return NULL;
}
s->stksize = size;
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -905,9 +905,18 @@ SQLinsert_val(READERtask *task, int col,
size_t slen = mystrlen(s);
// FIXME unchecked_malloc GDKmalloc can return
NULL, and asserts are not the way to check the result
char *scpy = GDKmalloc(slen + 1);
- assert(scpy);
- if (scpy)
- mycpstr(scpy, s);
+ if ( scpy == NULL){
+ task->rowerror[idx]++;
+ task->errorcnt++;
+ task->besteffort = 0; /* no longer best
effort */
+ BUNappend(task->cntxt->error_row, &row,
FALSE);
+ BUNappend(task->cntxt->error_fld, &col,
FALSE);
+ BUNappend(task->cntxt->error_msg,
MAL_MALLOC_FAIL, FALSE);
+ BUNappend(task->cntxt->error_input,
err, FALSE);
+ GDKfree(err);
+ return -1;
+ }
+ mycpstr(scpy, s);
s = scpy;
}
MT_lock_set(&errorlock);
diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c
--- a/monetdb5/modules/mal/txtsim.c
+++ b/monetdb5/modules/mal/txtsim.c
@@ -23,12 +23,12 @@
#include "mal_exception.h"
-// FIXME unchecked_malloc ATOMnil can return NULL
#define RETURN_NIL_IF(b,t) \
if (b) {\
if (ATOMextern(t)) {\
*(ptr*) res = (ptr) ATOMnil(t);\
- /* FIXME unchecked_malloc ATOMnil can return NULL */ \
+ if ( *(ptr *) res == NULL)\
+ throw(MAL,"txtsim", MAL_MALLOC_FAIL);\
} else {\
memcpy(res, ATOMnilptr(t), ATOMsize(t));\
}\
@@ -310,8 +310,9 @@ CMDqgramnormalize(str *res, str *Input)
char c, last = ' ';
RETURN_NIL_IF(strNil(input), TYPE_str);
- // FIXME unchecked_malloc GDKmalloc can return NULL
*res = (str) GDKmalloc(sizeof(char) * (strlen(input) + 1)); /*
normalized strings are never longer than original */
+ if (*res == NULL)
+ throw(MAL,"qgram",MAL_MALLOC_FAIL);
for (i = 0; input[i]; i++) {
c = toupper(input[i]);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list