[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Assert in test-aligned-malloc.c
From: |
Bruno Haible |
Subject: |
Re: Assert in test-aligned-malloc.c |
Date: |
Sun, 25 Oct 2020 21:07:42 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-189-generic; KDE/5.18.0; x86_64; ; ) |
Hi Gisle,
> On Windows/MSVC, I get an abort() on line 85:
>
> ASSERT (((uintptr_t) aligned16_blocks[i] % 16) == 0);
Works fine for me, with MSVC 14, in all possible combinations
(32 bit and 64 bit, with and without -MD).
> m4/malloc-align.m4 indicates that MALLOC_ALIGN should
> be 8 or 16.
Yes, MALLOC_ALIGN should be = 2 * sizeof (void*).
> #define MALLOC_ALIGNMENT 8 /* 2*sizeof(void*) in my case */
Can you investigate this assertion failure? I mean, for the alignment 16
> MALLOC_ALIGNMENT, the code is supposed to use code branch
/* Use malloc and waste a bit of memory. */
and this implementation cannot return a value that is not a multiple of 16.
Does the problem persist when you reduce the optimization options?
> But all (?) Windows targets do have the
> '_aligned_malloc()' [1] function which is found nowhere.
_aligned_malloc is a "Use malloc and waste a bit of memory" implementation
as well. Nothing more fancy or more efficient. It's equivalent to the one
I coded in aligned-malloc.h lines 127..167, just with fewer assertions and
thus more dangerous to use if someone makes programming mistakes.
Bruno