Hi Hadi,
On 2017-11-25 22:43:49 -0500, Hadi Moshayedi wrote:
> While doing some tests on REL_10_STABLE, I was getting run-time exceptions
> at int8_avg_combine() at the following line:
>
> state1->sumX = state2->sumX;
>
> After some debugging, I noticed that palloc()’s alignment is 8-bytes, while
> this statement (which moves a __int128 from one memory location to another
> memory location) expects 16-byte memory alignments. So when either state1
> or state2 is not 16-byte aligned, this crashes.
>
> When I disassemble the code, the above statement is translated to a pair of
> movdqa and movaps assignments when compiled with -O2:
>
> movdqa c(%rdx), %xmm0
> movaps %xmm0, c(%rcx)
>
> Looking at “Intel 64 and IA-32 Architectures Software Developer’s Manual,
> Volume 2”, both of these instructions expect 16-byte aligned memory
> locations, or a general-protection exception will be generated.
Nicely analyzed. [Un]fortunately the bug has already been found and
fixed:
https://git.postgresql.org/pg/commitdiff/619a8c47da7279c186bb57cc16b26ad011366b73
Will be included in the next set of back branch releases.
> diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h
> index 869c59dc85..2dc59e89cd 100644
> --- a/src/include/utils/memutils.h
> +++ b/src/include/utils/memutils.h
> @@ -189,7 +189,7 @@ extern MemoryContext SlabContextCreate(MemoryContext parent,
> * Few callers should be interested in this, but tuplesort/tuplestore need
> * to know it.
> */
> -#define ALLOCSET_SEPARATE_THRESHOLD 8192
> +#define ALLOCSET_SEPARATE_THRESHOLD 16384
Huh, what's that about in this context?
Greetings,
Andres Freund