This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 25b5bab22d [fix](memory) Fix hash table buf initialize null pointer (#21315) 25b5bab22d is described below commit 25b5bab22dfbb174b673759877c003eee34ed889 Author: Xinyi Zou <zouxiny...@gmail.com> AuthorDate: Fri Jun 30 14:50:53 2023 +0800 [fix](memory) Fix hash table buf initialize null pointer (#21315) When compiling FunctionArrayEnumerateUniq::_execute_by_hash, AllocatorWithStackMemory::free(buf) will be called when delete HashMapContainer. the gcc compiler will think that size > N and buf is not heap memory, and report an error ' void free(void*)' called on unallocated object 'hash_map' This only fails on doris docker + gcc 11.1, no problem on doris docker + clang 16.0.1, no problem on ldb_toolchanin gcc 11.1 and clang 16.0.1. --- be/src/vec/common/hash_table/hash_table.h | 4 ++-- .../vec/functions/array/function_array_enumerate_uniq.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/be/src/vec/common/hash_table/hash_table.h b/be/src/vec/common/hash_table/hash_table.h index 7ee35af64c..0b9d6bc3e1 100644 --- a/be/src/vec/common/hash_table/hash_table.h +++ b/be/src/vec/common/hash_table/hash_table.h @@ -445,8 +445,8 @@ protected: using Self = HashTable; using cell_type = Cell; - size_t m_size = 0; /// Amount of elements - Cell* buf; /// A piece of memory for all elements except the element with zero key. + size_t m_size = 0; /// Amount of elements + Cell* buf {nullptr}; /// A piece of memory for all elements except the element with zero key. Grower grower; int64_t _resize_timer_ns; diff --git a/be/src/vec/functions/array/function_array_enumerate_uniq.cpp b/be/src/vec/functions/array/function_array_enumerate_uniq.cpp index d40185f903..e3b8aa4bf6 100644 --- a/be/src/vec/functions/array/function_array_enumerate_uniq.cpp +++ b/be/src/vec/functions/array/function_array_enumerate_uniq.cpp @@ -105,6 +105,16 @@ public: return return_type; } +// When compiling `FunctionArrayEnumerateUniq::_execute_by_hash`, `AllocatorWithStackMemory::free(buf)` +// will be called when `delete HashMapContainer`. the gcc compiler will think that `size > N` and `buf` is not heap memory, +// and report an error `' void free(void*)' called on unallocated object 'hash_map'` +// This only fails on doris docker + gcc 11.1, no problem on doris docker + clang 16.0.1, +// no problem on ldb_toolchanin gcc 11.1 and clang 16.0.1. +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" +#endif // __GNUC__ + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, size_t result, size_t input_rows_count) override { ColumnRawPtrs data_columns(arguments.size()); @@ -285,6 +295,10 @@ private: } }; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + void register_function_array_enumerate_uniq(SimpleFunctionFactory& factory) { factory.register_function<FunctionArrayEnumerateUniq>(); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org