vesoft-inc / vesoft-inc/nebula-cpp

Memory leak in some conditions.

Open
#77 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/bug
Dominant language
C++
Stars
19
Forks
25
Avg merge
3d 2h
Merged PRs (30d)
1

Description

➜  build git:(fix/asan) ✗ ./bin/test/connection_test
[==========] Running 6 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 6 tests from ConnectionTest
[ RUN      ] ConnectionTest.Basic
I1215 17:46:28.031438 36440 ConnectionTest.cpp:120] Testing once.
E1215 17:46:28.031808 36440 Connection.cpp:217] Ping failed: Not open connection.
E1215 17:46:29.054208 36440 Connection.cpp:217] Ping failed: Not open connection.
E1215 17:46:29.054322 36440 Connection.cpp:217] Ping failed: Not open connection.
I1215 17:46:29.054392 36440 ConnectionTest.cpp:122] Testing reopen.
E1215 17:46:29.054426 36440 Connection.cpp:217] Ping failed: Not open connection.
E1215 17:46:30.066576 36440 Connection.cpp:217] Ping failed: Not open connection.
E1215 17:46:30.066687 36440 Connection.cpp:217] Ping failed: Not open connection.
[       OK ] ConnectionTest.Basic (2037 ms)
[ RUN      ] ConnectionTest.Timeout
[       OK ] ConnectionTest.Timeout (30142 ms)
[ RUN      ] ConnectionTest.SSL
[       OK ] ConnectionTest.SSL (14 ms)
[ RUN      ] ConnectionTest.JsonResult
[       OK ] ConnectionTest.JsonResult (5 ms)
[ RUN      ] ConnectionTest.InvalidPort
E1215 17:47:00.229737 36440 Connection.cpp:120] Failed to verify client version: Channel is !good()
[       OK ] ConnectionTest.InvalidPort (2 ms)
[ RUN      ] ConnectionTest.InvalidHost
E1215 17:47:00.233917 36440 Connection.cpp:86] Invalid address: Invalid Host:9669: Failed to resolve address for 'Invalid Host': Name or service not known (error=-2): Unknown error -2
[       OK ] ConnectionTest.InvalidHost (4 ms)
[----------] 6 tests from ConnectionTest (32204 ms total)

[----------] Global test environment tear-down
[==========] 6 tests from 1 test case ran. (32204 ms total)
[  PASSED  ] 6 tests.

=================================================================
==36440==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 944 byte(s) in 1 object(s) allocated from:
    #0 0xa4d867 in operator new(unsigned long) /usr/src/nebula-package/toolset-build/source/llvm-10.0.0/projects/compiler-rt/lib/asan/asan_new_delete.cpp:99:3
    #1 0x10c80f6 in folly::AsyncSocket::newSocket(folly::EventBase*, folly::SocketAddress const&, unsigned int, bool) /home/shylock.huang/local/vesoft/2.0/third-party/include/folly/io/async/AsyncSocket.h:364:9
    #2 0x10c7946 in nebula::Connection::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, unsigned int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::$_0::operator()() const /home/shylock.huang/nebula-cpp2/src/client/Connection.cpp:97:22
    #3 0x10c7094 in void folly::detail::function::FunctionTraits<void ()>::callBig<nebula::Connection::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, unsigned int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::$_0>(folly::detail::function::Data&) /home/shylock.huang/local/vesoft/2.0/third-party/include/folly/Function.h:385:7
    #4 0x145abf1  (/home/shylock.huang/nebula-cpp2/build/bin/test/connection_test+0x145abf1)
    #5 0x17be1df1c23ee  (<unknown module>)

SUMMARY: AddressSanitizer: 944 byte(s) leaked in 1 allocation(s).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect src/client/Connection.cpp around line 97, where the ASAN trace reports an allocation from Connection::open. Run build/bin/test/connection_test under LeakSanitizer and compare the ConnectionTest cases. Done means the tests still pass and LeakSanitizer reports no 944-byte leak.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.