alibaba / alibaba/yalantinglibs
MEMCHECK: 456 bytes in 1 blocks are possibly lost in loss record
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 327
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 2
Description
I’ve scanned yalantinglibs with MEMCHECK and it has triggered on yalantinglibs/include/ylt/thirdparty/async_simple/coro/PromiseAllocator.h line 325. I'm not sure whether this is an actual issue, or whether code of yalantinglibs is too sophisticated for MEMCHECK to understand. Do you guys have any idea?
## Project version
yalantinglibs: main
## Operating system
compiler: gcc (Debian 12.2.0-14) 12.2.0
Ubuntu 22.04.4 LTS
Linux 5.15.0-125-generic #135-Ubuntu SMP Fri Sep 27 13:53:58 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
## I did this
Launched yalantinglibs/build/output/examples/coro_http/coro_http_example
## I expected the following
No problem reported by MEMCHECK
## I got the following
yalantinglibs/build/output/examples/coro_http/coro_http_example
2025-04-05 13:26:31.868 INFO [7748] [coro_http_server.hpp:604] begin to listen 9001
^[[91m2025-04-05 13:26:32.405 ERROR ^[[0m^[[0K[7748] [coro_http_server.hpp:634] bind port: 9001 error: Address already in use
2025-04-05 13:26:33.564 TRACE [7748] [coro_http_client.hpp:2017] start resolve host: 127.0.0.1:9001
2025-04-05 13:26:34.632 TRACE [7766] [coro_http_client.hpp:2035] start connect to endpoint lists. total endpoint count:1, the first endpoint is: 127.0.0.19001
2025-04-05 13:26:35.710 TRACE [7766] [coro_http_client.hpp:2087] connect to endpoint: 127.0.0.1:9001 successfully
==7748== Memcheck, a memory error detector
==7748== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==7748== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==7748== Command: yalantinglibs/build/output/examples/coro_http/coro_http_example
==7748==
coro_http_example: yalantinglibs/src/coro_http/examples/example.cpp:432: async_simple::coro::Lazy basic_usage(): Assertion `result.status == 200' failed.
==7748==
...
==7748== 456 bytes in 1 blocks are possibly lost in loss record 99 of 122
==7748== at 0x4842A94: operator new[](unsigned long, std::nothrow_t const&) (coregrind/m_replacemalloc/vg_replace_malloc.c:747)
==7748== by 0x1A92A2: async_simple::coro::detail::PromiseAllocator::operator new(unsigned long) ( yalantinglibs/include/ylt/thirdparty/async_simple/coro/PromiseAllocator.h:325)
==7748== by 0x1D718D: async_simple::coro::Lazy coro_io::async_io(coro_io::period_timer::async_await()::{lambda(auto:1&&)#1}, coro_io::period_timer&) ( yalantinglibs/include/ylt/coro_io/coro_io.hpp:321)
==7748== by 0x11BC1E: coro_io::period_timer::async_await(coro_io::period_timer::async_await()::_ZN7coro_io12period_timer11async_awaitEv.Frame*) [clone .actor] ( yalantinglibs/include/ylt/coro_io/coro_io.hpp:504)
==7748== by 0x14EAFB: cinatra::coro_http_client::timeout(cinatra::coro_http_client::timeout(coro_io::period_timer&, std::chrono::duration >,
std::__cxx11::basic_string, std::allocator
>)::_ZN7cinatra16coro_http_client7timeoutIN7coro_io12period_timerEEEN12async_simple4coro4LazyIbEERT_NSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.Frame*) [clone .actor]
( yalantinglibs/include/ylt/standalone/cinatra/coro_http_client.hpp:2395)
==7748== by 0x14EDE0: async_simple::coro::detail::LazyBase::start >,
std::__cxx11::basic_string, std::allocator >)::{lambda(auto:1&&)#1}>(cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration >, std::__cxx11::basic_string, std::allocator >)::{lambda(auto:1&&)#1}&&)::{lambda(async_simple::coro::detail::LazyBase,
cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration >, std::__cxx11::basic_string, std::allocator
==7748== by 0x1DA2FF: async_simple::coro::detail::LazyBase::start >,
std::__cxx11::basic_string, std::allocator >)::{lambda(auto:1&&)#1}>(cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration >, std::__cxx11::basic_string, std::allocator >)::{lambda(auto:1&&)#1}&&)::{lambda(async_simple::coro::detail::LazyBase,
cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration >, std::__cxx11::basic_string, std::allocator
>)::{lambda(auto:1&&)#1})#1}::operator()(async_simple::coro::detail::LazyBase, cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration
>, std::__cxx11::basic_string, std::allocator >)::{lambda(auto:1&&)#1}) const ( yalantinglibs/include/ylt/thirdparty/async_simple/coro/Lazy.h:421)
==7748== by 0x1DA437: void async_simple::coro::detail::LazyBase::start >,
std::__cxx11::basic_string, std::allocator >)::{lambda(auto:1&&)#1}>(cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration >, std::__cxx11::basic_string, std::allocator >)::{lambda(auto:1&&)#1}&&) ( yalantinglibs/include/ylt/thirdparty/async_simple/coro/Lazy.h:426)
==7748== by 0x1B5BAD: cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration >, std::__cxx11::basic_string,
std::allocator >) ( yalantinglibs/include/ylt/standalone/cinatra/coro_http_client.hpp:646)
==7748== by 0x14CC4C: cinatra::coro_http_client::async_request(cinatra::coro_http_client::async_request, std::allocator >, std::__cxx11::basic_string, std::allocator > >(std::__cxx11::basic_string, std::allocator >, cinatra::http_method, cinatra::req_context, std::allocator > >, std::unordered_map, std::allocator >, std::__cxx11::basic_string, std::allocator
>, std::hash, std::allocator > >, std::equal_to, std::allocator > >,
std::allocator, std::allocator > const, std::__cxx11::basic_string, std::allocator > > > >, std::span)::_ZN7cinatra16coro_http_client13async_requestINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_EEN12async_simple4coro4LazyINS_9resp_dataEEET_NS_11http_methodENS_11req_contextIT0_EESt13unordered_mapI\
S7_S7_St4hashIS7_ESt8equal_toIS7_ESaISt4pairIKS7_S7_EEESt4spanIcLm18446744073709551615EE.Frame*) [clone .actor] ( yalantinglibs/include/ylt/standalone/cinatra/coro_http_client.hpp:1363)
==7748== by 0x127AB3: cinatra::coro_http_client::connect(cinatra::coro_http_client::connect(cinatra::uri_t const&, std::vector, std::allocator >
>*)::_ZN7cinatra16coro_http_client7connectERKNS_5uri_tEPSt6vectorIN4asio2ip14basic_endpointINS6_3tcpEEESaIS9_EE.Frame*) [clone .actor] ( yalantinglibs/include/ylt/standalone/cinatra/coro_http_client.hpp:2006)
==7748== by 0x15136E: coro_io::async_connect(coro_io::async_connect, 0ul> >, std::vector,
std::allocator > > >(coro_io::ExecutorWrapper, 0ul> >*, asio::basic_stream_socket&,
std::vector, std::allocator > >
const&)::_ZN7coro_io13async_connectINS_15ExecutorWrapperIN4asio10io_context19basic_executor_typeISaIvELm0EEEEESt6vectorINS2_2ip14basic_endpointINS9_3tcpEEESaISC_EEEEN12async_simple4coro4LazyISt4pairISt10error_codeSC_EEEPT_RNS2_19\
basic_stream_socketISB_NS2_15any_io_executorEEERKT0_.Frame*) [clone .actor] ( yalantinglibs/include/ylt/coro_io/coro_io.hpp:441)
==7748==
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with include/ylt/thirdparty/async_simple/coro/PromiseAllocator.h:325 and trace the allocation through include/ylt/thirdparty/async_simple/coro/Lazy.h:421-426, then inspect the related coroutine paths in coro_io.hpp and coro_http_client.hpp named in the report. Reproduce the coro_http_example Memcheck run after resolving the reported port conflict and assertion; done means determining whether the 456-byte allocation is genuinely unreleased or a Memcheck false positive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100