Changeset: 69c30038c87d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/69c30038c87d
Modified Files:
gdk/gdk_bat.c
Branch: Dec2023
Log Message:
Make a copy of the string heap hash table while locked.
Fixes bug #7495.
diffs (46 lines):
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -801,6 +801,7 @@ COLcopy(BAT *b, int tt, bool writable, r
bool slowcopy = false;
BAT *bn = NULL;
BATiter bi;
+ char strhash[GDK_STRHASHSIZE];
BATcheck(b, NULL);
assert(tt != TYPE_bat);
@@ -814,7 +815,24 @@ COLcopy(BAT *b, int tt, bool writable, r
return NULL;
}
- bi = bat_iterator(b);
+ /* in case of a string bat, we save the string heap hash table
+ * while we have the lock so that we can restore it in the copy;
+ * this is because during our operation, a parallel thread could
+ * be adding strings to the vheap which would modify the hash
+ * table and that would result in buckets containing values
+ * beyond the original vheap that we're copying */
+ MT_lock_set(&b->theaplock);
+ bi = bat_iterator_nolock(b);
+ if (ATOMstorage(b->ttype) == TYPE_str && b->tvheap->free >=
GDK_STRHASHSIZE)
+ memcpy(strhash, b->tvheap->base, GDK_STRHASHSIZE);
+
+#ifndef NDEBUG
+ bi.locked = true;
+#endif
+ HEAPincref(bi.h);
+ if (bi.vh)
+ HEAPincref(bi.vh);
+ MT_lock_unset(&b->theaplock);
/* first try case (1); create a view, possibly with different
* atom-types */
@@ -894,6 +912,8 @@ COLcopy(BAT *b, int tt, bool writable, r
memcpy(bn->tvheap->base, bi.vh->base,
bi.vhfree);
bn->tvheap->free = bi.vhfree;
bn->tvheap->dirty = true;
+ if (ATOMstorage(b->ttype) == TYPE_str &&
b->tvheap->free >= GDK_STRHASHSIZE)
+ memcpy(b->tvheap->base, strhash,
GDK_STRHASHSIZE);
}
/* make sure we use the correct capacity */
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]