Changeset: f5d7970fdffe for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f5d7970fdffe
Modified Files:
        monetdb5/extras/jaql/jaqlscenario.c
        monetdb5/mal/mal_import.c
        sql/backends/monet5/sql.mx
        sql/backends/monet5/sql_scenario.c
Branch: Feb2013
Log Message:

added assertions to detect memory leaks when clearing & restoring the global 
variable stack (c->glb)


diffs (107 lines):

diff --git a/monetdb5/extras/jaql/jaqlscenario.c 
b/monetdb5/extras/jaql/jaqlscenario.c
--- a/monetdb5/extras/jaql/jaqlscenario.c
+++ b/monetdb5/extras/jaql/jaqlscenario.c
@@ -285,6 +285,7 @@ JAQLengine(Client c)
         * workaround */
        chkProgram(c->fdout, c->nspace, c->curprg->def);
 
+       assert(c->glb == 0 || c->glb == oldglb); /* detect leak */
        c->glb = 0;
        if (j->explain) {
                printFunction(c->fdout, c->curprg->def, 0, LIST_MAL_STMT | 
LIST_MAPI);
@@ -318,6 +319,7 @@ JAQLengine(Client c)
 
        MSresetInstructions(c->curprg->def, 1);
        freeVariables(c, c->curprg->def, c->glb, j->vtop);
+       assert(c->glb == 0 || c->glb == oldglb); /* detect leak */
        c->glb = oldglb;
 
        freetree(j->p);
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -145,6 +145,7 @@ malLoadScript(Client c, str name, bstrea
        c->prompt = oldprompt; \
        c->promptlength= (int)strlen(c->prompt);
 #define restoreClient2 \
+       assert(c->glb == 0 || c->glb == oldglb); /* detect leak */ \
        c->glb = oldglb; \
        c->nspace = oldnspace; \
        c->curprg = oldprg;
diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx
--- a/sql/backends/monet5/sql.mx
+++ b/sql/backends/monet5/sql.mx
@@ -7682,6 +7682,7 @@ RAstatement(Client cntxt, MalBlkPtr mb, 
                        resetMalBlk(cntxt->curprg->def, oldstop);
                        freeVariables(cntxt,cntxt->curprg->def, cntxt->glb, 
oldvtop);
                }
+               assert(cntxt->glb == 0 || cntxt->glb == oldglb); /* detect leak 
*/
                cntxt->glb = oldglb;
        }
        return msg;
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -1024,6 +1024,7 @@ SQLstatementIntern(Client c, str *expr, 
                        execute = 0;
                        if (!err)
                                continue;
+                       assert(c->glb == 0 || c->glb == oldglb); /* detect leak 
*/
                        c->glb = oldglb;
                        goto endofcompile;
                }
@@ -1052,6 +1053,7 @@ SQLstatementIntern(Client c, str *expr, 
                        MSresetInstructions(c->curprg->def, oldstop);
                        freeVariables(c,c->curprg->def, c->glb, oldvtop);
                        c->curprg->def->errors = 0;
+                       assert(c->glb == 0 || c->glb == oldglb); /* detect leak 
*/
                        c->glb = oldglb;
                        goto endofcompile;
                }
@@ -1067,6 +1069,7 @@ SQLstatementIntern(Client c, str *expr, 
                        freeVariables(c,c->curprg->def, c->glb, oldvtop);
                        c->curprg->def->errors = 0;
                        msg = createException(SQL, "SQLparser","Errors 
encountered in query");
+                       assert(c->glb == 0 || c->glb == oldglb); /* detect leak 
*/
                        c->glb = oldglb;
                        goto endofcompile;
                }
@@ -1085,12 +1088,14 @@ SQLstatementIntern(Client c, str *expr, 
                }
                sqlcleanup(m, 0);
                if (!execute) {
+                       assert(c->glb == 0 || c->glb == oldglb); /* detect leak 
*/
                        c->glb = oldglb;
                        goto endofcompile;
                }
 #ifdef _SQL_COMPILE
        mnstr_printf(c->fdout, "#parse/execute result %d\n", err);
 #endif
+               assert(c->glb == 0 || c->glb == oldglb); /* detect leak */
                c->glb = oldglb;
        }
 /*
@@ -1950,6 +1955,7 @@ SQLengineIntern(Client c, backend *be)
        if( m->emode == m_prepare)
                goto cleanup_engine;
 
+       assert(c->glb == 0 || c->glb == oldglb); /* detect leak */
        c->glb = 0;
        be->language = 'D';
        /*
@@ -1972,6 +1978,7 @@ cleanup_engine:
                        MSresetInstructions(c->curprg->def, 1);
                        freeVariables(c,c->curprg->def, c->glb, be->vtop);
                        be->language = oldlang;
+                       assert(c->glb == 0 || c->glb == oldglb); /* detect leak 
*/
                        c->glb = oldglb;
                        return SQLrecompile(c, be);
                } else {
@@ -2011,6 +2018,7 @@ cleanup_engine:
         * Any error encountered during execution should block further 
processing
         * unless auto_commit has been set.
         */
+       assert(c->glb == 0 || c->glb == oldglb); /* detect leak */
        c->glb = oldglb;
        return msg;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to