Skip to content

Commit

Permalink
Fix sparse expression parsing memory leak (#1338)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

```
=================================================================
==58327==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 576 byte(s) in 24 object(s) allocated from:
    #0 0x55be02292f41 in operator new(unsigned long) (/infinity/cmake-build-debug/src/infinity+0x707f41) (BuildId: a8a47e2552e9916f1f7d2b289e095233935d70f4)
    #1 0x55be051ac8d0 in sqlparse(void*, infinity::ParserResult*) /infinity/cmake-build-debug/parser.y:2942:39
    #2 0x55be050f73b8 in infinity::SQLParser::Parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, infinity::ParserResult*) /infinity/src/parser/sql_parser.cpp:39:9
    #3 0x55be02a13141 in infinity::QueryContext@query_context::Query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /infinity/src/main/query_context.cpp:90:14
    #4 0x55be02454cbb in infinity::Connection@connection::HandlerSimpleQuery(infinity::QueryContext@query_context*) /infinity/src/network/connection.cpp:155:41
    #5 0x55be024541b3 in infinity::Connection@connection::HandleRequest() /infinity/src/network/connection.cpp:131:13
    #6 0x55be0245219b in infinity::Connection@connection::Run() /infinity/src/network/connection.cpp:70:13
    #7 0x55be0284b0ac in infinity::PGServer@pg_server::StartConnection(std::shared_ptr<infinity::Connection@connection>&)::$_0::operator()() /infinity/src/network/pg_server.cpp:81:25
    #8 0x55be0284b004 in void std::__invoke_impl<void, infinity::PGServer@pg_server::StartConnection(std::shared_ptr<infinity::Connection@connection>&)::$_0>(std::__invoke_other, infinity::PGServer@pg_server::StartConnection(std::shared_ptr<infinity::Connection@connection>&)::$_0&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:61:14
    #9 0x55be0284afc4 in std::__invoke_result<infinity::PGServer@pg_server::StartConnection(std::shared_ptr<infinity::Connection@connection>&)::$_0>::type std::__invoke<infinity::PGServer@pg_server::StartConnection(std::shared_ptr<infinity::Connection@connection>&)::$_0>(infinity::PGServer@pg_server::StartConnection(std::shared_ptr<infinity::Connection@connection>&)::$_0&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:96:14
    #10 0x55be0284af9c in void std::thread::_Invoker<std::tuple<infinity::PGServer@pg_server::StartConnection(std::shared_ptr<infinity::Connection@connection>&)::$_0>>::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:292:13
    #11 0x55be0284af74 in std::thread::_Invoker<std::tuple<infinity::PGServer@pg_server::StartConnection(std::shared_ptr<infinity::Connection@connection>&)::$_0>>::operator()() /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:299:11
    #12 0x55be0284ade8 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<infinity::PGServer@pg_server::StartConnection(std::shared_ptr<infinity::Connection@connection>&)::$_0>>>::_M_run() /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_thread.h:244:13
    #13 0x55be05869602 in execute_native_thread_routine thread.o
```

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
  • Loading branch information
JinHai-CN authored Jun 16, 2024
1 parent acd10c1 commit e9a484b
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 1,074 deletions.
18 changes: 13 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,19 @@ elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "-O0 -g")
set(CMAKE_C_FLAGS "-O0 -g")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking ")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fno-omit-frame-pointer")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=cfi -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector -fno-var-tracking ")
add_compile_options(-fsanitize=address -fsanitize-recover=all -fsanitize=leak)
add_link_options(-fsanitize=address -fsanitize-recover=all -fsanitize=leak)

add_compile_options("-fno-omit-frame-pointer")
add_link_options("-fno-omit-frame-pointer")

# add_compile_options("-fsanitize=undefined")
# add_link_options("-fsanitize=undefined")

# add_compile_options("-fsanitize=thread")
# add_link_options("-fsanitize=thread")

set(CMAKE_DEBUG_POSTFIX "")

else ()
Expand Down
29 changes: 0 additions & 29 deletions benchmark/polling_scheduler/CMakeLists.txt

This file was deleted.

39 changes: 0 additions & 39 deletions benchmark/polling_scheduler/buffer.h

This file was deleted.

41 changes: 0 additions & 41 deletions benchmark/polling_scheduler/buffer_queue.h

This file was deleted.

42 changes: 0 additions & 42 deletions benchmark/polling_scheduler/fragment.cpp

This file was deleted.

99 changes: 0 additions & 99 deletions benchmark/polling_scheduler/fragment.h

This file was deleted.

76 changes: 0 additions & 76 deletions benchmark/polling_scheduler/operator.h

This file was deleted.

Loading

0 comments on commit e9a484b

Please sign in to comment.