diff --git a/dbms/src/Common/AlignedBuffer.cpp b/dbms/src/Common/AlignedBuffer.cpp index b60813bfeae..6d4775ebadf 100644 --- a/dbms/src/Common/AlignedBuffer.cpp +++ b/dbms/src/Common/AlignedBuffer.cpp @@ -16,9 +16,10 @@ namespace ErrorCodes void AlignedBuffer::alloc(size_t size, size_t alignment) { void * new_buf; - int res = ::posix_memalign(&new_buf, alignment, size); + int res = ::posix_memalign(&new_buf, std::max(alignment, sizeof(void*)), size); if (0 != res) - throwFromErrno("Cannot allocate memory (posix_memalign) " + formatReadableSizeWithBinarySuffix(size) + ".", + throwFromErrno("Cannot allocate memory (posix_memalign), size: " + + formatReadableSizeWithBinarySuffix(size) + ", alignment: " + formatReadableSizeWithBinarySuffix(alignment) + ".", ErrorCodes::CANNOT_ALLOCATE_MEMORY, res); buf = new_buf; }