Changeset: edcca34a8a35 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=edcca34a8a35
Modified Files:
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_runtime.c
Branch: Dec2016
Log Message:

Fix double entry in  sys.queue
The constant expression optimizer could add an entry to the
sys.queue without removing it before returning.


diffs (82 lines):

diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -479,6 +479,7 @@ str runMALsequence(Client cntxt, MalBlkP
        int stkpc = 0;
        RuntimeProfileRecord runtimeProfile, runtimeProfileFunction;
        lng lastcheck = 0;
+       int     startedProfileQueue = 0;
 #define CHECKINTERVAL 1000 /* how often do we check for client disconnect */
        runtimeProfile.ticks = runtimeProfileFunction.ticks = 0;
 
@@ -519,6 +520,7 @@ str runMALsequence(Client cntxt, MalBlkP
 
        /* also produce event record for start of function */
        if ( startpc == 1 &&  startpc < mb->stop ){
+               startedProfileQueue = 1;
                runtimeProfileInit(cntxt, mb, stk);
                runtimeProfileBegin(cntxt, mb, stk, getInstrPtr(mb,0), 
&runtimeProfileFunction);
                mb->starttime = GDKusec();
@@ -769,7 +771,6 @@ str runMALsequence(Client cntxt, MalBlkP
                                ret = shutdownFactory(cntxt, mb);
                        runtimeProfileExit(cntxt, mb, stk, pci, 
&runtimeProfile);
                        runtimeProfileExit(cntxt, mb, stk, getInstrPtr(mb,0), 
&runtimeProfileFunction);
-                       runtimeProfileFinish(cntxt, mb);
                        if (pcicaller && garbageControl(getInstrPtr(mb, 0)))
                                garbageCollector(cntxt, mb, stk, TRUE);
                        if (cntxt->qtimeout && GDKusec()- mb->starttime > 
cntxt->qtimeout){
@@ -802,8 +803,6 @@ str runMALsequence(Client cntxt, MalBlkP
                if( mb->stop <= 1)
                        continue;
                runtimeProfileExit(cntxt, mb, stk, pci, &runtimeProfile);
-               if (ret != MAL_SUCCEED)
-                       runtimeProfileFinish(cntxt, mb);
                /* check for strong debugging after each MAL statement */
                if ( pci->token != FACcall && ret== MAL_SUCCEED) {
                        for (i = 0; i < pci->retc; i++) {
@@ -1141,7 +1140,6 @@ str runMALsequence(Client cntxt, MalBlkP
                        if (stkpc == mb->stop) {
                                runtimeProfileExit(cntxt, mb, stk, pci, 
&runtimeProfile);
                                runtimeProfileExit(cntxt, mb, stk, 
getInstrPtr(mb,0), &runtimeProfileFunction);
-                               runtimeProfileFinish(cntxt, mb);
                                break;
                        }
                        if (stkpc == mb->stop)
@@ -1149,6 +1147,8 @@ str runMALsequence(Client cntxt, MalBlkP
                                        "Exception raised");
                        break;
                case YIELDsymbol:     /* to be defined */
+                       if( startedProfileQueue)
+                               runtimeProfileFinish(cntxt, mb);
                        if ( backup != backups) GDKfree(backup);
                        if ( garbage != garbages) GDKfree(garbage);
                        return yieldFactory(mb, pci, stkpc);
@@ -1175,7 +1175,6 @@ str runMALsequence(Client cntxt, MalBlkP
                                        /* reset the clock */
                                        runtimeProfileExit(cntxt, mb, stk, pp, 
&runtimeProfile);
                                        runtimeProfileExit(cntxt, mb, stk, 
getInstrPtr(mb,0), &runtimeProfileFunction);
-                                       runtimeProfileFinish(cntxt, mb);
                                } 
                        }
                        stkpc = mb->stop;
@@ -1209,6 +1208,8 @@ str runMALsequence(Client cntxt, MalBlkP
                }
                freeException(oldret);
        }
+       if( startedProfileQueue)
+               runtimeProfileFinish(cntxt, mb);
        if ( backup != backups) GDKfree(backup);
        if ( garbage != garbages) GDKfree(garbage);
        return ret;
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -100,6 +100,8 @@ runtimeProfileFinish(Client cntxt, MalBl
        int i,j;
 
        (void) cntxt;
+       if( QRYqueue == NULL)
+               return;
 
        MT_lock_set(&mal_delayLock);
        for( i=j=0; i< qtop; i++)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to