Changeset: c2c514c2ebf7 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c2c514c2ebf7 Modified Files: monetdb5/optimizer/opt_costModel.c monetdb5/optimizer/opt_evaluate.c Branch: Jul2017 Log Message:
Turn on defense lines for expression optimizer SQLsmith triggered a case where a plan, probably with array overflow, was accepted for execution. diffs (69 lines): diff --git a/monetdb5/optimizer/opt_costModel.c b/monetdb5/optimizer/opt_costModel.c --- a/monetdb5/optimizer/opt_costModel.c +++ b/monetdb5/optimizer/opt_costModel.c @@ -150,7 +150,7 @@ OPTcostModelImplementation(Client cntxt, //chkDeclarations(cntxt->fdout, mb); /* keep all actions taken as a post block comment */ usec = GDKusec()- usec; - snprintf(buf,256,"%-20s actions=1 time=" LLFMT " usec","costmodel",usec); + snprintf(buf,256,"%-20s actions= 1 time=" LLFMT " usec","costmodel",usec); newComment(mb,buf); addtoMalBlkHistory(mb); diff --git a/monetdb5/optimizer/opt_evaluate.c b/monetdb5/optimizer/opt_evaluate.c --- a/monetdb5/optimizer/opt_evaluate.c +++ b/monetdb5/optimizer/opt_evaluate.c @@ -118,11 +118,11 @@ str OPTevaluateImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { InstrPtr p; - int i, k, limit, *alias = 0, barrier; + int i, k, limit, barrier; MalStkPtr env = NULL; int profiler; int debugstate = cntxt->itrace, actions = 0, constantblock = 0; - int *assigned = 0, use; + int *alias = 0, *assigned = 0, atop, use; char buf[256]; lng usec = GDKusec(); str msg = MAL_SUCCEED; @@ -139,11 +139,12 @@ OPTevaluateImplementation(Client cntxt, fprintf(stderr, "Constant expression optimizer started\n"); #endif - assigned = (int*) GDKzalloc(sizeof(int) * mb->vtop); + atop = mb->vsize *2; /* we possibly introduce more variables */ + assigned = (int*) GDKzalloc(sizeof(int) * atop); if (assigned == NULL) throw(MAL,"optimzier.evaluate", MAL_MALLOC_FAIL); - alias = (int*)GDKzalloc(mb->vsize * sizeof(int) * 2); /* we introduce more */ + alias = (int*)GDKzalloc(sizeof(int) * atop); if (alias == NULL){ GDKfree(assigned); throw(MAL,"optimzier.evaluate", MAL_MALLOC_FAIL); @@ -159,8 +160,10 @@ OPTevaluateImplementation(Client cntxt, // The double count emerging from a barrier exit is ignored. if (! blockExit(p) || (blockExit(p) && p->retc != p->argc)) for ( k =0; k < p->retc; k++) - if ( p->retc != p->argc || p->token != ASSIGNsymbol ) + if ( p->retc != p->argc || p->token != ASSIGNsymbol ){ + assert(getArg(p,k) < atop); assigned[getArg(p,k)]++; + } } for (i = 1; i < limit && cntxt->mode != FINISHCLIENT; i++) { @@ -244,9 +247,9 @@ OPTevaluateImplementation(Client cntxt, /* Defense line against incorrect plans */ /* Plan is unaffected */ - //chkTypes(cntxt->fdout, cntxt->nspace, mb, FALSE); - //chkFlow(cntxt->fdout, mb); - //chkDeclarations(cntxt->fdout, mb); + chkTypes(cntxt->fdout, cntxt->nspace, mb, FALSE); + chkFlow(cntxt->fdout, mb); + chkDeclarations(cntxt->fdout, mb); /* keep all actions taken as a post block comment */ usec = GDKusec()- usec; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list