Changeset: 73a5d014f6ac for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=73a5d014f6ac
Modified Files:
        MonetDB/src/gdk/gdk_align.mx
        MonetDB5/src/mal/mal_interpreter.mx
Branch: default
Log Message:

small improvements, to prevent crashes in case of 'out of memory'.


diffs (90 lines):

diff -r 617e10d1b5fa -r 73a5d014f6ac MonetDB/src/gdk/gdk_align.mx
--- a/MonetDB/src/gdk/gdk_align.mx      Sun Dec 05 14:08:55 2010 +0100
+++ b/MonetDB/src/gdk/gdk_align.mx      Sun Dec 05 14:34:32 2010 +0100
@@ -218,6 +218,8 @@
        recycled = bs = BBPrecycle(TYPE_void, TYPE_void, 1);
        if (bs == NULL)
                bs = BATcreatedesc(h->htype, TYPE_void, FALSE);
+       if (bs == NULL)
+               return NULL;
        bn = &bs->B;
 
        BATsetdims(bn);
@@ -267,8 +269,10 @@
        BATcheck(h, "VIEWcreate_");
        BATcheck(t, "VIEWcreate_");
        recycled = bs = BBPrecycle(TYPE_void, TYPE_void, 1);
-       if (!bs)
+       if (bs == NULL)
                bs = BATcreatedesc(h->htype, t->ttype, FALSE);
+       if (bs == NULL)
+               return NULL;
        bn = &bs->B;
 
        hp = VIEWhparent(h);
diff -r 617e10d1b5fa -r 73a5d014f6ac MonetDB5/src/mal/mal_interpreter.mx
--- a/MonetDB5/src/mal/mal_interpreter.mx       Sun Dec 05 14:08:55 2010 +0100
+++ b/MonetDB5/src/mal/mal_interpreter.mx       Sun Dec 05 14:34:32 2010 +0100
@@ -97,6 +97,8 @@
 #define heapinfo(X) if((X) && (X)->base) vol = (X)->free; else vol = 0;
 #define hashinfo(X) if((X) && (X)->mask) vol = 
((X)->mask+(X)->lim+1)*sizeof(int) + sizeof(*(X)); else vol = 0;
 
+#define FREE_EXCEPTION(p) { if (p && p != M5OutOfMemory) GDKfree(p); }
+
 @-
 The struct alignment leads to 40% gain in simple instructions when set.
 @c
@@ -1146,7 +1148,7 @@
                err = fs->pc >0 ? DFLOWstep(task, fs): 
createException(MAL,"interpreter","flow step failed");
                /* restore the instruction and wait in specific cases*/
                if ( err != MAL_SUCCEED && strstr(err,"DFLOWadmission") != NULL 
&& strstr(err,"failed") != NULL){
-                       GDKfree(err);
+                       FREE_EXCEPTION(err);
                        fs->pc = ABS(fs->pc);
                        fs->status = DFLOWrunning;
                        q_requeue(task->todo,fs);
@@ -1613,7 +1615,7 @@
                        ret = createScriptException(mb, mb->stop-1,
                                        
getExceptionType(getVarName(mb,exceptionVar)),
                                        ret, "Exception not caught");
-                       GDKfree(oldret);
+                       FREE_EXCEPTION(oldret);
                } else {
                        if (stk->stk[exceptionVar].vtype == TYPE_str) {
                                ret = createScriptException(mb, mb->stop-1, MAL,
@@ -2320,7 +2322,7 @@
 if(cntxt->errbuf && cntxt->errbuf[0] ) {
        str oldret = ret;
        ret = catchKernelException(cntxt, oldret);
-       if( oldret) GDKfree(oldret);
+       FREE_EXCEPTION(oldret);
 }
 
 if( ret != MAL_SUCCEED ) {
@@ -2344,7 +2346,7 @@
        /* Detect any exception received from the implementation. */
        /* The first identifier is an optional exception name */
        if( strstr(ret,"!skip-to-end") ){
-               GDKfree(ret);                   /* no need to check for 
M5OutOfMemory */
+               GDKfree(ret);           /* no need to check for M5OutOfMemory */
                ret= MAL_SUCCEED;
                stkpc= mb->stop;
                @2;
@@ -2374,15 +2376,14 @@
        if (getVarType(mb,exceptionVar) == TYPE_str){
                v=  &stk->stk[exceptionVar];
                if ( v->val.sval)
-                       GDKfree(v->val.sval);   /* old exception*/
+                       FREE_EXCEPTION(v->val.sval);    /* old exception*/
                v->vtype = TYPE_str;
                v->val.sval= ret;
                v->len= (int)strlen(v->val.sval);
                ret = 0;
        } else {
                mnstr_printf(cntxt->fdout,"%s",ret);
-               if (ret != M5OutOfMemory)
-                       GDKfree(ret);
+               FREE_EXCEPTION(ret);
        }
        /* position yourself at the catch instruction for further decisions */
        @:skipToCatch(exceptionVar,@2,@3)@
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to