Changeset: 006b01024195 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=006b01024195
Modified Files:
        MonetDB/src/gdk/gdk_bbp.mx
Branch: Jun2010
Log Message:

Completed old change where BATs and reversed BATs can be named independently.

It used to be that when you named a BAT, the name applied to the BAT
as a whole, so when you then looked up the BAT by name you would
actually get its reverse (mirror).  That was changed long ago.  This
fix completes this change.  It could happen that unnamed mirrors ended
up in the BBP_hash table (used to look up BATs by name) which would
not be removed when the BAT was deleted, resulting in NULL pointer
dereferences.


diffs (87 lines):

diff -r d5f1d669b7fa -r 006b01024195 MonetDB/src/gdk/gdk_bbp.mx
--- a/MonetDB/src/gdk/gdk_bbp.mx        Thu Sep 02 15:40:12 2010 +0200
+++ b/MonetDB/src/gdk/gdk_bbp.mx        Fri Sep 03 14:03:49 2010 +0200
@@ -364,20 +364,21 @@
 
        for (BBP_mask = 1; (BBP_mask << 1) <= BBPlimit; BBP_mask <<= 1)
                ;
-       BBP_hash = (bat *) GDKmalloc(BBP_mask * sizeof(bat));
+       BBP_hash = (bat *) GDKzalloc(BBP_mask * sizeof(bat));
        if (BBP_hash == NULL)
                GDKfatal("BBPinithash: cannot allocate memory\n");
-       memset(BBP_hash, 0, BBP_mask * sizeof(bat));
        BBP_mask--;
 
        while (--i > 0) {
                str s = BBP_logical(i);
 
                if (s) {
+                       str sm = BBP_logical(-i);
+
                        if (*s != '.' && BBPtmpcheck(s) == 0) {
                                BBP_insert(i);
                        }
-                       if (BBP_logical(-i)) {
+                       if (sm && *sm != '.' && BBPtmpcheck(sm) == 0) {
                                BBP_insert(-i);
                        }
                } else {
@@ -1638,18 +1639,18 @@
                BBP_delete(i);
                gdk_unset_lock(GDKnameLock, "bbpclear");
        }
-       if (BBP_logical(-i)) {
+       if (BBPtmpcheck(BBP_logical(-i)) == 0) {
                gdk_set_lock(GDKnameLock, "bbpclear");
                BBP_delete(-i);
                gdk_unset_lock(GDKnameLock, "bbpclear");
-               if (BBP_logical(-i) != BBP[ABS(i)].bak[(-i) < 0])
-                       GDKfree(BBP_logical(-i));
-               BBP_logical(-i) = NULL;
        }
        if (BBP_logical(i) != BBP[ABS(i)].bak[(i) < 0])
                GDKfree(BBP_logical(i));
+       if (BBP_logical(-i) != BBP[ABS(i)].bak[(-i) < 0])
+               GDKfree(BBP_logical(-i));
        BBP_status_set(i, 0, "BBPclear");
        BBP_logical(i) = NULL;
+       BBP_logical(-i) = NULL;
        BBP_next(i) = BBP_free(idx);
        BBP_free(idx) = i;
        if (lock)
@@ -2914,7 +2915,10 @@
                bc->elt[bc->last].fifo_next = i;
        bc->last = i;
 
-       *BBP_logical(bid) = '.';        /* make the bat a zombie */
+       /* make the bat a zombie */
+       *BBP_logical(bid) = '.';
+       *BBP_logical(-bid) = '.';
+
        MT_unset_lock(bc->lock, "batcache_put");
 
        return i;
@@ -2959,6 +2963,7 @@
 
                /* revive the bat */
                *BBP_logical(bid) = 't';
+               *BBP_logical(-bid) = 't';
                BBP_refs(bid)++;
 
                BATDEBUG {
@@ -2981,6 +2986,7 @@
        int bin = BATCACHE_BIN(b->htype, b->ttype);
        bat bid = b->batCacheid, hp = VIEWhparent(b), tp = VIEWtparent(b), vhp 
= VIEWhparent(b), vtp = VIEWtparent(b);
        char *s = BBP_logical(bid);
+       char *sm = BBP_logical(-bid);
        BAT *m = BBP_cache(-bid);
 
        /* only cache simple non-saved non-renamed transient bats */
@@ -2991,6 +2997,7 @@
            (b->T->heap.storage != STORE_MEM) ||
            b->P->lview ||
            BBPtmpcheck(s) == 0 ||
+           BBPtmpcheck(sm) == 0 ||
            (b->htype == TYPE_str && b->H->width > 1) ||
            (b->ttype == TYPE_str && b->T->width > 1) ||
            b->htype > TYPE_str ||
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to