Changeset: 0910cb497596 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0910cb497596
Modified Files:
        gdk/gdk.h
        gdk/gdk_atoms.c
        geom/monetdb5/geom.c
        monetdb5/modules/atoms/blob.c
Branch: Jul2015
Log Message:

Mark heap dirty when written into.
This fixes a potential crash when a BAT is decref-ed to physical 0 and
logical > 0, and then freed because the system thought it was clean.
When the BAT is subsequently incref-ed, it may not get loaded because
the data might not all be on disk.  This patch makes that the BAT
doesn't get freed, and hence doesn't have to be loaded.


diffs (52 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1239,6 +1239,7 @@ gdk_export bte ATOMelmshift(int sz);
        do {                                                    \
                assert((b)->HT->width == (s));                  \
                (b)->HT->heap.free += (s);                      \
+               (b)->HT->heap.dirty |= (s) != 0;                \
                HTputvalue((b), HT##loc((b), (p)), (v), 0, HT); \
        } while (0)
 #define hfastins_nocheck(b, p, v, s)   HTfastins_nocheck(b, p, v, s, H)
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -1312,6 +1312,7 @@ strPut(Heap *h, var_t *dst, const char *
 #endif
        }
        h->free += pad + len + extralen;
+       h->dirty = 1;
 
        /* maintain hash table */
        pos -= extralen;
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -615,8 +615,10 @@ wkbPUT(Heap *h, var_t *bun, wkb *val)
 
        *bun = HEAP_malloc(h, wkb_size(val->len));
        base = h->base;
-       if (*bun)
+       if (*bun) {
                memcpy(&base[*bun << GDK_VARSHIFT], (char *) val, 
wkb_size(val->len));
+               h->dirty = 1;
+       }
        return *bun;
 }
 
diff --git a/monetdb5/modules/atoms/blob.c b/monetdb5/modules/atoms/blob.c
--- a/monetdb5/modules/atoms/blob.c
+++ b/monetdb5/modules/atoms/blob.c
@@ -86,8 +86,10 @@ blob_put(Heap *h, var_t *bun, blob *val)
 
        *bun = HEAP_malloc(h, blobsize(val->nitems));
        base = h->base;
-       if (*bun)
+       if (*bun) {
                memcpy(&base[*bun << GDK_VARSHIFT], (char *) val, 
blobsize(val->nitems));
+               h->dirty = 1;
+       }
        return *bun;
 }
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to