Changeset: 630d6c4d0e55 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/630d6c4d0e55 Modified Files: gdk/gdk_select.c Branch: Dec2023 Log Message:
Fixed a potential deadlock. Thread A has heaplock for bat 24688 and tries to unfix its parent, bat 112. Thread B is trying to incref bat 24688 and already has the swaplock and now tries to get the heaplock. Note that the swaplock for bats 24688 and 112 are the same (modulo 8192); so thread A wants swaplock(112) while it has heaplock(24688), and thread B has swaplock(112) and wants heaplock(24688). Fixed by delaying the unfix in thread A until after the heaplock was released. This happened in function BATrange. diffs (40 lines): diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1235,10 +1235,10 @@ BATrange(BATiter *bi, const void *tl, co maxval = VALptr(maxprop); maxincl = false; } + bool keep = false; /* keep lock on parent bat? */ if (minprop == NULL || maxprop == NULL) { if (VIEWtparent(bi->b) && (pb = BATdescriptor(VIEWtparent(bi->b))) != NULL) { - bool keep = false; MT_lock_set(&pb->theaplock); if (minprop == NULL && (minprop = BATgetprop_nolock(pb, GDK_MIN_BOUND)) != NULL) { keep = true; @@ -1251,8 +1251,6 @@ BATrange(BATiter *bi, const void *tl, co } if (!keep) { MT_lock_unset(&pb->theaplock); - BBPreclaim(pb); - pb = NULL; } } } @@ -1340,12 +1338,13 @@ BATrange(BATiter *bi, const void *tl, co } } + MT_lock_unset(&bi->b->theaplock); if (pb) { - MT_lock_unset(&pb->theaplock); + if (keep) + MT_lock_unset(&pb->theaplock); BBPreclaim(pb); } - MT_lock_unset(&bi->b->theaplock); return range; } _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org