-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Hi,
On windows, the value of the alignment parameter to xmallocaligned, seems to occationally be 1 in some runs of tkrzw_file_perf, where it's a copy of PositionalParallelFileImpl::block_size_, while it's value is assert-ed to be at least sizeof(void*) in tkrzw_lib_common.cc:59:
58 #elif defined(_SYS_WINDOWS_)
59 ---> assert(alignment >= sizeof(void*));
60 size = AlignNumber(size, alignment);
61 void* ptr = _aligned_malloc(size, alignment);
62 if (ptr == nullptr) {
63 throw std::bad_alloc();
64 }
65 return ptr;
66 #else
This is most likely a consequence of it's value having been default initialized to 1 in the constructor of PositionalParallelFileImpl as well as the value passed to its' Setter-Procedure, SetAccessStrategy, invoked from tkrzw_file_perf.cc:283, defaulting to 1 in tkrzw_file_perf.cc:276, too.
In VCMakefile:165, among others, tkrzw_file_perf is invoked without explicitly specififying the --block_size, therefore a defaut value of 1 is used, and the statement asserted in tkrzw_lib_common.cc:59 is not provided.
Though the assertion is in a Windows specific branch, all Windows builds suppress it's evaluation by inconditionally setting the NDEBUG macro in VCMakefile:35.
As the assertion in tkrzw_lib_common.cc:59 never has an effect due to the macro, it shouldn't be there.
Also, assert should not be used to handle invalid input the implemenation can recover from, and this error seems to be recoverable, since it's currently taking place.