Description
Hello
I have a loop that inserts 4 byte values into a HLL. It hits a Valgrind warning
With these parameters:
Log2m = 11;
Regwidth = 5;
Expthresh = -1;
Sparseon = 1;
it happens after inserting 160 elements.
It seems as if multiset_packed_size computes a too-small size for the packed buffer that has to be used.
Valgrind warnings look as follows. Line numbers are off because I've been playing with this part of the code outside Postgres.
==29406== Invalid read of size 8
==29406== at 0x40B2D2: bitstream_pack (byteswap.h:111)
==29406== by 0x40BBD8: multiset_pack (hll.c:245)
==29406== Address 0x548e387 is 311 bytes inside a block of size 317 alloc'd
==29406== Invalid write of size 8
==29406== at 0x40B2E4: bitstream_pack (hll.c:155)
==29406== by 0x40BBD8: multiset_pack (hll.c:245)
==29406== Address 0x548e387 is 311 bytes inside a block of size 317 alloc'd
which is this line: * (uint64_t *) bwcp->bwc_curp = qw;
Hopefully this is enough info to find the bug, otherwise I can dig more. I'm reasonably sure you can reproduce this with HLL running inside Postgres, but it's harder to Valgrind there.
I can also build a test against the original HLL source if that will help you.
Cheers
Albert