This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 5f0479b20 fix: gcc15 compiler warning `free-nonheap-object` in
`cmd_search.cc` (#3172)
5f0479b20 is described below
commit 5f0479b2071d16eebbba378e857f1efca6472cd4
Author: Edward Xu <[email protected]>
AuthorDate: Thu Oct 2 20:46:14 2025 +0800
fix: gcc15 compiler warning `free-nonheap-object` in `cmd_search.cc` (#3172)
# Issue
fix #3165
# Root cause
This root cause is a new feature in gcc15.2 `free-nonheap-object`.
Here is the error message. It's in link stage.
IMHO it makes me confused at the first time I saw errors like this.
```
[5/7] Linking CXX executable kvrocks
In member function 'deallocate',
inlined from 'deallocate' at
/usr/local/include/c++/15.2.0/bits/alloc_traits.h:649:23,
inlined from '_M_destroy' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:305:34,
inlined from '_M_dispose' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:299:14,
inlined from '__dt_base ' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:896:19,
inlined from '__dt_base ' at /build/src/common/status.h:170:3,
inlined from '__dt_base ' at /build/src/common/status.h:362:23,
inlined from 'Execute' at /build/src/commands/cmd_search.cc:543:25:
/usr/local/include/c++/15.2.0/bits/new_allocator.h:172:66: warning:
'operator delete' called on unallocated object '<anonymous>'
[-Wfree-nonheap-object]
172 | _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n));
| ^
/build/src/commands/cmd_search.cc: In member function 'Execute':
/build/src/commands/cmd_search.cc:543:25: note: declared here
543 | auto field_values = GET_OR_RET(srv->index_mgr.TagValues(ctx,
index_name, tag_field_name, conn->GetNamespace()));
| ^
In member function 'deallocate',
inlined from 'deallocate' at
/usr/local/include/c++/15.2.0/bits/alloc_traits.h:649:23,
inlined from '_M_destroy' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:305:34,
inlined from '_M_dispose' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:299:14,
inlined from '__dt_base ' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:896:19,
inlined from '__dt_base ' at /build/src/common/status.h:170:3,
inlined from '__dt_base ' at /build/src/common/status.h:362:23,
inlined from 'Execute' at /build/src/commands/cmd_search.cc:543:25:
/usr/local/include/c++/15.2.0/bits/new_allocator.h:172:66: warning:
'operator delete' called on unallocated object '<anonymous>'
[-Wfree-nonheap-object]
172 | _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n));
| ^
/build/src/commands/cmd_search.cc: In member function 'Execute':
/build/src/commands/cmd_search.cc:543:25: note: declared here
543 | auto field_values = GET_OR_RET(srv->index_mgr.TagValues(ctx,
index_name, tag_field_name, conn->GetNamespace()));
| ^
[6/7] Linking CXX executable kvrocks2redis
In member function 'deallocate',
inlined from 'deallocate' at
/usr/local/include/c++/15.2.0/bits/alloc_traits.h:649:23,
inlined from '_M_destroy' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:305:34,
inlined from '_M_dispose' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:299:14,
inlined from '__dt_base ' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:896:19,
inlined from '__dt_base ' at /build/src/common/status.h:170:3,
inlined from '__dt_base ' at /build/src/common/status.h:362:23,
inlined from 'Execute' at /build/src/commands/cmd_search.cc:543:25:
/usr/local/include/c++/15.2.0/bits/new_allocator.h:172:66: warning:
'operator delete' called on unallocated object '<anonymous>'
[-Wfree-nonheap-object]
172 | _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n));
| ^
/build/src/commands/cmd_search.cc: In member function 'Execute':
/build/src/commands/cmd_search.cc:543:25: note: declared here
543 | auto field_values = GET_OR_RET(srv->index_mgr.TagValues(ctx,
index_name, tag_field_name, conn->GetNamespace()));
| ^
In member function 'deallocate',
inlined from 'deallocate' at
/usr/local/include/c++/15.2.0/bits/alloc_traits.h:649:23,
inlined from '_M_destroy' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:305:34,
inlined from '_M_dispose' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:299:14,
inlined from '__dt_base ' at
/usr/local/include/c++/15.2.0/bits/basic_string.h:896:19,
inlined from '__dt_base ' at /build/src/common/status.h:170:3,
inlined from '__dt_base ' at /build/src/common/status.h:362:23,
inlined from 'Execute' at /build/src/commands/cmd_search.cc:543:25:
/usr/local/include/c++/15.2.0/bits/new_allocator.h:172:66: warning:
'operator delete' called on unallocated object '<anonymous>'
[-Wfree-nonheap-object]
172 | _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n));
| ^
/build/src/commands/cmd_search.cc: In member function 'Execute':
/build/src/commands/cmd_search.cc:543:25: note: declared here
543 | auto field_values = GET_OR_RET(srv->index_mgr.TagValues(ctx,
index_name, tag_field_name, conn->GetNamespace()));
|
```
If I understand correctly, it should caused by the dtor of `Status`.
https://github.com/apache/kvrocks/blob/dfdd2105df3b206e95accea217d50d70dbbee220/src/common/status.h#L358-L364
# Proposed Changes
Mitigate this problem by implicitly checking the status without the
`GET_OR_RET` macro.
---------
Co-authored-by: Twice <[email protected]>
---
src/commands/cmd_search.cc | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/commands/cmd_search.cc b/src/commands/cmd_search.cc
index dab2fc718..31d29fc3e 100644
--- a/src/commands/cmd_search.cc
+++ b/src/commands/cmd_search.cc
@@ -540,9 +540,12 @@ class CommandFTTagVals : public Commander {
Status Execute(engine::Context &ctx, Server *srv, Connection *conn,
std::string *output) override {
const auto &index_name = args_[1];
const auto &tag_field_name = args_[2];
- auto field_values = GET_OR_RET(srv->index_mgr.TagValues(ctx, index_name,
tag_field_name, conn->GetNamespace()));
+ auto field_values = srv->index_mgr.TagValues(ctx, index_name,
tag_field_name, conn->GetNamespace());
+ if (!field_values) {
+ return field_values;
+ }
- std::vector<std::string> result_vec(field_values.begin(),
field_values.end());
+ std::vector<std::string> result_vec(field_values->begin(),
field_values->end());
*output = conn->SetOfBulkStrings(result_vec);