Changeset: 5afabdf4e13d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5afabdf4e13d Modified Files: clients/mapiclient/mclient.c gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_bbp.c gdk/gdk_join.c gdk/gdk_project.c gdk/gdk_storage.c monetdb5/mal/mal_instruction.c monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_session.c tools/merovingian/utils/control.c Branch: linear-hashing Log Message:
merged with nov2019 diffs (261 lines): diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -124,6 +124,8 @@ static timertype t0, t1; /* used for tim #ifdef HAVE_POPEN static char *pager = 0; /* use external pager */ +#endif +#ifdef HAVE_SIGACTION #include <signal.h> /* to block SIGPIPE */ #endif static int rowsperpage = 0; /* for SQL pagination */ @@ -1808,36 +1810,27 @@ start_pager(stream **saveFD) if (pager) { FILE *p; - struct sigaction act; - /* ignore SIGPIPE so that we get an error instead of signal */ - act.sa_handler = SIG_IGN; - (void) sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if(sigaction(SIGPIPE, &act, NULL) == -1) { + p = popen(pager, "w"); + if (p == NULL) fprintf(stderr, "Starting '%s' failed\n", pager); - } else { - p = popen(pager, "w"); - if (p == NULL) + else { + *saveFD = toConsole; + /* put | in name to indicate that file should be closed with pclose */ + if ((toConsole = file_wastream(p, "|pager")) == NULL) { + toConsole = *saveFD; + *saveFD = NULL; fprintf(stderr, "Starting '%s' failed\n", pager); - else { - *saveFD = toConsole; - /* put | in name to indicate that file should be closed with pclose */ - if ((toConsole = file_wastream(p, "|pager")) == NULL) { + } +#ifdef HAVE_ICONV + if (encoding != NULL) { + if ((toConsole = iconv_wstream(toConsole, encoding, "pager")) == NULL) { toConsole = *saveFD; *saveFD = NULL; fprintf(stderr, "Starting '%s' failed\n", pager); } -#ifdef HAVE_ICONV - if (encoding != NULL) { - if ((toConsole = iconv_wstream(toConsole, encoding, "pager")) == NULL) { - toConsole = *saveFD; - *saveFD = NULL; - fprintf(stderr, "Starting '%s' failed\n", pager); - } - } + } #endif - } } } } @@ -3336,6 +3329,16 @@ main(int argc, char **argv) exit(2); } #endif +#ifdef HAVE_SIGACTION + struct sigaction act; + /* ignore SIGPIPE so that we get an error instead of signal */ + act.sa_handler = SIG_IGN; + (void) sigemptyset(&act.sa_mask); + act.sa_flags = 0; + if (sigaction(SIGPIPE, &act, NULL) == -1) + perror("sigaction"); +#endif + toConsole = stdout_stream = file_wastream(stdout, "stdout"); stderr_stream = file_wastream(stderr, "stderr"); if(!stdout_stream || !stderr_stream) { diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -1271,7 +1271,7 @@ BUNinplace(BAT *b, BUN p, const void *t, ptr _ptr; _ptr = BUNtloc(bi, p); switch (b->twidth) { - case 1: + default: /* only three or four cases possible */ _d = (var_t) * (uint8_t *) _ptr + GDK_VAROFFSET; break; case 2: @@ -1296,7 +1296,7 @@ BUNinplace(BAT *b, BUN p, const void *t, } _ptr = BUNtloc(bi, p); switch (b->twidth) { - case 1: + default: /* only three or four cases possible */ * (uint8_t *) _ptr = (uint8_t) (_d - GDK_VAROFFSET); break; case 2: diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -961,7 +961,7 @@ BATreplace(BAT *b, BAT *p, BAT *n, bool var_t d; switch (b->twidth) { - case 1: + default: /* only three of four cases possible */ d = (var_t) ((uint8_t *) b->theap.base)[updid] + GDK_VAROFFSET; break; case 2: diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -1456,8 +1456,11 @@ BBPinit(void) /* try to obtain a BBP.dir from bakdir */ if (stat(backupbbpdirstr, &st) == 0) { /* backup exists; *must* use it */ - if (recover_dir(0, stat(bbpdirstr, &st) == 0) != GDK_SUCCEED) + if (recover_dir(0, stat(bbpdirstr, &st) == 0) != GDK_SUCCEED) { + GDKfree(bbpdirstr); + GDKfree(backupbbpdirstr); goto bailout; + } if ((fp = GDKfilelocate(0, "BBP", "r", "dir")) == NULL) { GDKfree(bbpdirstr); GDKfree(backupbbpdirstr); @@ -1471,8 +1474,11 @@ BBPinit(void) /* no BBP.bak (nor BBP.dir or BACKUP/BBP.dir): * create a new one */ IODEBUG fprintf(stderr, "#BBPdir: initializing BBP.\n"); /* BBPdir instead of BBPinit for backward compatibility of error messages */ - if (BBPdir(0, NULL) != GDK_SUCCEED) + if (BBPdir(0, NULL) != GDK_SUCCEED) { + GDKfree(bbpdirstr); + GDKfree(backupbbpdirstr); goto bailout; + } } else if (GDKmove(0, BATDIR, "BBP", "bak", BATDIR, "BBP", "dir") == GDK_SUCCEED) IODEBUG fprintf(stderr, "#BBPinit: reverting to dir saved in BBP.bak.\n"); @@ -1753,14 +1759,14 @@ BBPdir_subcommit(int cnt, bat *subcommit if ((obbpf = GDKfileopen(0, SUBDIR, "BBP", "dir", "r")) == NULL && (obbpf = GDKfileopen(0, BAKDIR, "BBP", "dir", "r")) == NULL) { GDKerror("BBPdir: subcommit attempted without backup BBP.dir."); - return GDK_FAIL; + goto bailout; } /* read first three lines */ if (fgets(buf, sizeof(buf), obbpf) == NULL || /* BBP.dir, GDKversion %d */ fgets(buf, sizeof(buf), obbpf) == NULL || /* SIZEOF_SIZE_T SIZEOF_OID SIZEOF_MAX_INT */ fgets(buf, sizeof(buf), obbpf) == NULL) { /* BBPsize=%d */ GDKerror("BBPdir: subcommit attempted with invalid backup BBP.dir."); - return GDK_FAIL; + goto bailout; } /* third line contains BBPsize */ sscanf(buf, "BBPsize=%d", &n); diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c --- a/gdk/gdk_join.c +++ b/gdk/gdk_join.c @@ -3455,7 +3455,7 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B } phash = sr == NULL && VIEWtparent(r) != 0 && - BATcount(BBPquickdesc(VIEWtparent(r), false)) == BATcount(r); + BATcount(BBP_cache(VIEWtparent(r))) == BATcount(r); return hashjoin(r1p, r2p, l, r, sl, sr, &lci, &rci, nil_matches, nil_on_miss, semi, only_misses, not_in, estimate, t0, false, phash, func); diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c --- a/gdk/gdk_project.c +++ b/gdk/gdk_project.c @@ -389,6 +389,7 @@ BATproject(BAT *l, BAT *r) /* handle string trick */ if (stringtrick) { + assert(r->tvheap); if (r->batRestricted == BAT_READ) { /* really share string heap */ assert(r->tvheap->parentid > 0); diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c --- a/gdk/gdk_storage.c +++ b/gdk/gdk_storage.c @@ -165,7 +165,8 @@ GDKremovedir(int farmid, const char *dir } path = GDKfilepath(farmid, dirname, dent->d_name, NULL); if (path == NULL) { - ret = -1; + /* most likely the rmdir will now fail causing + * an error return */ goto bailout; } ret = remove(path); 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 @@ -891,7 +891,7 @@ trimMalVariables_(MalBlkPtr mb, MalStkPt fprintf(stderr,"used %s %d\n", getVarName(mb,i), isVarUsed(mb,i)); #endif if ( isVarUsed(mb,i) == 0) { - if (glb && isVarConstant(mb, i)) + if (glb && i < glb->stktop && isVarConstant(mb, i)) VALclear(&glb->stk[i]); freeVariable(mb, i); continue; @@ -906,7 +906,7 @@ trimMalVariables_(MalBlkPtr mb, MalStkPt /* valgrind finds a leak when we move these variable record * pointers around. */ alias[i] = cnt; - if (glb && i != cnt) { + if (glb && i < glb->stktop && i != cnt) { glb->stk[cnt] = glb->stk[i]; VALempty(&glb->stk[i]); } 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 @@ -1421,8 +1421,10 @@ void garbageCollector(Client cntxt, MalB } #endif assert(mb->vtop <= mb->vsize); + assert(stk->stktop <= stk->stksize); (void) flag; - for (k = 0; k < mb->vtop; k++) { + (void)mb; + for (k = 0; k < stk->stktop; k++) { // if (isVarCleanup(mb, k) ){ garbageElement(cntxt, v = &stk->stk[k]); v->vtype = TYPE_int; diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c --- a/monetdb5/mal/mal_session.c +++ b/monetdb5/mal/mal_session.c @@ -442,7 +442,7 @@ MSresetVariables(Client cntxt, MalBlkPtr assert(!mb->var[i].value.vtype || isVarConstant(mb, i)); setVarUsed(mb,i); } - if (glb && !isVarUsed(mb,i)) { + if (i < glb->stktop && glb && !isVarUsed(mb,i)) { if (isVarConstant(mb, i)) garbageElement(cntxt, &glb->stk[i]); /* clean stack entry */ diff --git a/tools/merovingian/utils/control.c b/tools/merovingian/utils/control.c --- a/tools/merovingian/utils/control.c +++ b/tools/merovingian/utils/control.c @@ -102,6 +102,7 @@ char* control_send( continue; if (connect(sock, rp->ai_addr, (socklen_t) rp->ai_addrlen) != SOCKET_ERROR) break; /* success */ + closesocket(sock); } freeaddrinfo(res); if (rp == NULL) { @@ -112,7 +113,6 @@ char* control_send( strerror(errno) #endif ); - closesocket(sock); return(strdup(sbuf)); } #if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list