Initialize overflow of hash buckets to nil before use.
Initialize overflow of hash buckets to nil before use.

Without doing this we were getting strange segfaults for addresses down
in the 0xff00 range when dereferencing the b->overflow field in
hash_insert().

I narrowed down the problem to only occurring after reentering the
"again" loop as the result of hash_grow() invalidating the entire
hashmap.  When hash_grow() returns, h->buckets points to a completely
new region for holding buckets, but a reference to the original set of
buckets is kept in h->oldbuckets, so that entries from it can be
lazily copied out on demand. The memory for the new h->buckets seems
to have been reaped from the garbage collector (not a new mmap).

In the case when we enter the "again" loop after a hash_grow(), we end
up calling grow_work(), which calls evacuate(), which has some crazy
logic for figuring out which parts of our original bucket to copy out
from h->oldbuckets[i] to the new h->buckets[i]. This logic doesn't
seem to 0 out the overflow field of the new buckets by default.  If
the reaped memory wasn't zeroed out before handing it back to us, we
get screwed.  I'm not sure what the normal semantics for this are with
the go garbage collector.

Anyway, simply adding a few lines to the evacuate() function before
any other copying is done:

        x->overflow = nil;
        y->overflow = nil;

seems to fix the problem, and all other go tests still function as
expected -- both on linux and on akaros. Given that they don't even have
this file in the tip of their hg repo anymore, I'm committing this small
change here and moving on.

klueska/go-akaros,klueska/go-akaros,klueska/go-akaros,klueska/go-akaros,klueska/go-akaros,klueska/go-akaros,klueska/go-akaros,klueska/go-akaros