Changeset: 0b1b358b41c1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0b1b358b41c1
Modified Files:
monetdb5/modules/atoms/mtime.c
Branch: escape-sequences
Log Message:
merged with default
diffs (truncated from 4276 to 300 lines):
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -789,3 +789,4 @@ 43d4a717410d6f6692a16a878640fc7e0f248725
43d4a717410d6f6692a16a878640fc7e0f248725 Jan2022_SP6_release
5c50a4071c86d1621e20a885a51cc36f2f23eec4 Sep2022_9
41ca60d96bd0198ca5d74937630a442a5fbaf1cd Sep2022_11
+41ca60d96bd0198ca5d74937630a442a5fbaf1cd Sep2022_SP1_release
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -217,7 +217,6 @@ bat BBPlimit;
void BBPlock(void);
BAT *BBPquickdesc(bat b);
int BBPreadBBPline(FILE *fp, unsigned bbpversion, int *lineno, BAT *bn, int
*hashash, char *batname, char *filename, char **options);
-int BBPreclaim(BAT *b);
int BBPrelease(bat b);
int BBPrename(BAT *b, const char *nme);
int BBPretain(bat b);
@@ -305,7 +304,6 @@ size_t GDKmallocated(const void *s);
size_t GDKmem_cursize(void);
gdk_return GDKmergeidx(BAT *b, BAT **a, int n_ar);
void *GDKmmap(const char *path, int mode, size_t len)
__attribute__((__warn_unused_result__));
-gdk_return GDKmmapfile(char *buffer, size_t max, size_t id);
int GDKms(void);
gdk_return GDKmunmap(void *addr, size_t len);
int GDKnr_threads;
diff --git a/clients/examples/C/streamcat.c b/clients/examples/C/streamcat.c
--- a/clients/examples/C/streamcat.c
+++ b/clients/examples/C/streamcat.c
@@ -164,7 +164,7 @@ int cmd_read(char *argv[])
s = opener(filename);
if (s == NULL || mnstr_errnr(s) != MNSTR_NO__ERROR) {
- char *msg = mnstr_error(s);
+ const char *msg = mnstr_peek_error(s);
croak(2, "Opener %s failed: %s", opener_name, msg ? msg : "<no
error message>");
}
@@ -200,7 +200,7 @@ int cmd_read(char *argv[])
if (wrapper != NULL)
s = wrapper(s, parms);
if (s == NULL || mnstr_errnr(s) != MNSTR_NO__ERROR) {
- char *msg = mnstr_error(s);
+ const char *msg = mnstr_peek_error(s);
croak(2, "Opener %s failed: %s", opener_name, msg ? msg
: "<no error message>");
}
}
@@ -269,7 +269,7 @@ int cmd_write(char *argv[])
s = opener(filename);
if (s == NULL || mnstr_errnr(s) != MNSTR_NO__ERROR) {
- char *msg = mnstr_error(NULL);
+ const char *msg = mnstr_peek_error(NULL);
croak(2, "Opener %s failed: %s", opener_name, msg ? msg : "");
}
@@ -313,7 +313,7 @@ int cmd_write(char *argv[])
if (wrapper != NULL)
s = wrapper(s, parms);
if (s == NULL || mnstr_errnr(s) != MNSTR_NO__ERROR) {
- char *msg = mnstr_error(s);
+ const char *msg = mnstr_peek_error(s);
croak(2, "Opener %s failed: %s", opener_name, msg ? msg
: "<no error message>");
}
}
@@ -350,7 +350,7 @@ static void copy_stream_to_file(stream *
iterations += 1;
nread = mnstr_read(in, buffer, 1, bufsize);
if (nread < 0)
- croak(2, "Error reading from stream after %" PRIu64 "
bytes: %s", total, mnstr_error(in));
+ croak(2, "Error reading from stream after %" PRIu64 "
bytes: %s", total, mnstr_peek_error(in));
if (nread == 0) {
// eof
break;
@@ -395,15 +395,15 @@ static void copy_file_to_stream(FILE *in
}
nwritten = mnstr_write(out, buffer, 1, nread);
if (nwritten < 0)
- croak(2, "Write error after %" PRId64 " bytes: %s",
total, mnstr_error(out));
+ croak(2, "Write error after %" PRId64 " bytes: %s",
total, mnstr_peek_error(out));
if ((size_t)nwritten != nread)
croak(2, "Partial write (%lu/%lu bytes) after %" PRId64
" bytes: %s",
(unsigned long)nwritten, (unsigned long)nread,
- total + (int64_t)nwritten, mnstr_error(out));
+ total + (int64_t)nwritten,
mnstr_peek_error(out));
total += (int64_t)nwritten;
if (do_flush)
if (mnstr_flush(out, flush_level) != 0)
- croak(2, "Flush failed after %" PRId64 " bytes:
%s", total, mnstr_error(out));
+ croak(2, "Flush failed after %" PRId64 " bytes:
%s", total, mnstr_peek_error(out));
}
free(buffer);
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -276,9 +276,7 @@ main(int argc, char **argv)
mapi_destroy(mid);
if (mnstr_errnr(out) != MNSTR_NO__ERROR) {
- char *err = mnstr_error(out);
- fprintf(stderr, "%s: %s\n", argv[0], err);
- free(err);
+ fprintf(stderr, "%s: %s\n", argv[0], mnstr_peek_error(out));
return 1;
}
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1588,9 +1588,7 @@ close_result(MapiHdl hdl)
if (mnstr_printf(mid->to, "%s", msg) < 0 ||
mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
close_connection(mid);
- char *err = mnstr_error(mid->to);
- mapi_setError(mid, err, __func__,
MTIMEOUT);
- free(err);
+ mapi_setError(mid,
mnstr_peek_error(mid->to), __func__, MTIMEOUT);
break;
}
read_into_cache(hdl, 0);
@@ -1608,9 +1606,7 @@ close_result(MapiHdl hdl)
if (mnstr_printf(mid->to, "%s", msg) < 0 ||
mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
close_connection(mid);
- char *err = mnstr_error(mid->to);
- mapi_setError(mid, err, __func__,
MTIMEOUT);
- free(err);
+ mapi_setError(mid,
mnstr_peek_error(mid->to), __func__, MTIMEOUT);
} else
read_into_cache(hdl, 0);
}
@@ -1834,9 +1830,7 @@ finish_handle(MapiHdl hdl)
if (mnstr_printf(mid->to, "%s", msg) < 0 ||
mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
close_connection(mid);
- char *err = mnstr_error(mid->to);
- mapi_setError(mid, err, __func__, MTIMEOUT);
- free(err);
+ mapi_setError(mid, mnstr_peek_error(mid->to),
__func__, MTIMEOUT);
break;
}
read_into_cache(hdl, 0);
@@ -3428,9 +3422,7 @@ mapi_Xcommand(Mapi mid, const char *cmdn
if (mnstr_printf(mid->to, "X" "%s %s\n", cmdname, cmdvalue) < 0 ||
mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
close_connection(mid);
- char *err = mnstr_error(mid->to);
- mapi_setError(mid, err, __func__, MTIMEOUT);
- free(err);
+ mapi_setError(mid, mnstr_peek_error(mid->to), __func__,
MTIMEOUT);
return MERROR;
}
if (mid->tracelog) {
@@ -4740,9 +4732,7 @@ mapi_cache_limit(Mapi mid, int limit)
if (mnstr_printf(mid->to, "X" "reply_size %d\n", limit) < 0 ||
mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) {
close_connection(mid);
- char *err = mnstr_error(mid->to);
- mapi_setError(mid, err, __func__, MTIMEOUT);
- free(err);
+ mapi_setError(mid, mnstr_peek_error(mid->to), __func__,
MTIMEOUT);
return MERROR;
}
hdl = prepareQuery(mapi_new_handle(mid), "reply_size");
diff --git a/gdk/ChangeLog.Sep2022 b/gdk/ChangeLog.Sep2022
--- a/gdk/ChangeLog.Sep2022
+++ b/gdk/ChangeLog.Sep2022
@@ -1,3 +1,8 @@
# ChangeLog file for GDK
# This file is updated with Maddlog
+* Thu Dec 8 2022 Sjoerd Mullender <[email protected]>
+- When extending a bat failed, the capacity had been updated already and
+ was therefore too large. This could then later cause a crash. This has
+ been fixed by only updating the capacity if the extend succeeded.
+
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -1975,8 +1975,7 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT
bailout:
bat_iterator_end(&bi);
bailout1:
- if (bn)
- BBPunfix(bn->batCacheid);
+ BBPreclaim(bn);
GDKfree(rems);
if (cntsp) {
BBPreclaim(*cntsp);
@@ -3720,8 +3719,7 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
MT_lock_unset(&pb->theaplock);
}
}
- if (pb)
- BBPunfix(pb->batCacheid);
+ BBPreclaim(pb);
}
if (aggr == NULL) {
s = ATOMlen(bi.type, res);
@@ -3873,8 +3871,7 @@ BATmax_skipnil(BAT *b, void *aggr, bit s
MT_lock_unset(&pb->theaplock);
}
}
- if (pb)
- BBPunfix(pb->batCacheid);
+ BBPreclaim(pb);
}
if (aggr == NULL) {
s = ATOMlen(bi.type, res);
@@ -4240,8 +4237,7 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
}
if (oidxh != NULL)
HEAPdecref(oidxh, false);
- if (t1)
- BBPunfix(t1->batCacheid);
+ BBPreclaim(t1);
gdk_return rc = BUNappend(bn, v, false);
bat_iterator_end(&bi);
if (rc != GDK_SUCCEED)
@@ -4272,8 +4268,7 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
BBPunfix(b->batCacheid);
if (g && g != origg)
BBPunfix(g->batCacheid);
- if (bn)
- BBPunfix(bn->batCacheid);
+ BBPreclaim(bn);
return NULL;
}
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -548,9 +548,11 @@ BATextend(BAT *b, BUN newcap)
TRC_DEBUG(HEAP, "HEAPgrow in BATextend %s %zu %zu\n",
b->theap->filename, b->theap->size, theap_size);
rc = HEAPgrow(&b->theap, theap_size, b->batRestricted ==
BAT_READ);
+ if (rc == GDK_SUCCEED)
+ b->batCapacity = newcap;
+ } else {
+ b->batCapacity = newcap;
}
-
- b->batCapacity = newcap;
MT_lock_unset(&b->theaplock);
return rc;
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2703,8 +2703,7 @@ BATsort(BAT **sorted, BAT **order, BAT *
MT_lock_unset(&pb->batIdxLock);
if (oidxh)
HEAPdecref(oidxh, false);
- if (bn)
- BBPunfix(bn->batCacheid);
+ BBPreclaim(bn);
if (pb && pb != b)
BBPunfix(pb->batCacheid);
BBPreclaim(on);
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3015,30 +3015,6 @@ BATdescriptor(bat i)
}
/*
- * BBPreclaim is a user-exported function; the common way to destroy a
- * BAT the hard way.
- *
- * Return values:
- * -1 = bat cannot be unloaded (it has more than your own memory fix)
- * 0 = unloaded successfully
- * 1 = unload failed (due to write-to-disk failure)
- */
-int
-BBPreclaim(BAT *b)
-{
- bat i;
- bool lock = locked_by == 0 || locked_by != MT_getpid();
-
- if (b == NULL)
- return -1;
- i = b->batCacheid;
-
- assert(BBP_refs(i) == 1);
-
- return decref(i, false, lock, __func__) < 0;
-}
-
-/*
* BBPdescriptor checks whether BAT needs loading and does so if
* necessary. You must have at least one fix on the BAT before calling
* this.
diff --git a/gdk/gdk_bbp.h b/gdk/gdk_bbp.h
--- a/gdk/gdk_bbp.h
+++ b/gdk/gdk_bbp.h
@@ -70,7 +70,6 @@ gdk_export int BBPreadBBPline(FILE *fp,
gdk_export gdk_return BBPaddfarm(const char *dirname, uint32_t rolemask, bool
logerror);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]