Skip to content

MEMCHECK: 456 bytes in 1 blocks are possibly lost in loss record #976

Open

Description

@JohnSmithBH84

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<void> 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<void, true>::operator new(unsigned long) ( yalantinglibs/include/ylt/thirdparty/async_simple/coro/PromiseAllocator.h:325)
==7748==    by 0x1D718D: async_simple::coro::Lazy<std::error_code> coro_io::async_io<std::error_code, coro_io::period_timer::async_await()::{lambda(auto:1&&)#1},
    coro_io::period_timer>(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>(coro_io::period_timer&, std::chrono::duration<long, std::ratio<1l, 1000000000l> >,
    std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
    >)::_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<bool, false>::start<cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration<long, std::ratio<1l, 1000000000l> >,
    std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(auto:1&&)#1}>(cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration<long, std::ratio<1l,
    1000000000l> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(auto:1&&)#1}&&)::{lambda(async_simple::coro::detail::LazyBase<bool, false>,
    cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration<long, std::ratio<1l, 1000000000l> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
==7748==    by 0x1DA2FF: async_simple::coro::detail::LazyBase<bool, false>::start<cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration<long, std::ratio<1l, 1000000000l> >,
    std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(auto:1&&)#1}>(cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration<long, std::ratio<1l,
    1000000000l> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(auto:1&&)#1}&&)::{lambda(async_simple::coro::detail::LazyBase<bool, false>,
    cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration<long, std::ratio<1l, 1000000000l> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
    >)::{lambda(auto:1&&)#1})#1}::operator()(async_simple::coro::detail::LazyBase<bool, false>, cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration<long, std::ratio<1l, 1000000000l>
    >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(auto:1&&)#1}) const ( yalantinglibs/include/ylt/thirdparty/async_simple/coro/Lazy.h:421)
==7748==    by 0x1DA437: void async_simple::coro::detail::LazyBase<bool, false>::start<cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration<long, std::ratio<1l, 1000000000l> >,
    std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(auto:1&&)#1}>(cinatra::coro_http_client::timer_guard::timer_guard(cinatra::coro_http_client*, std::chrono::duration<long, std::ratio<1l,
    1000000000l> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{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<long, std::ratio<1l, 1000000000l> >, std::__cxx11::basic_string<char, std::char_traits<char>,
    std::allocator<char> >) ( 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::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char,
    std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, cinatra::http_method, cinatra::req_context<std::__cxx11::basic_string<char,
    std::char_traits<char>, std::allocator<char> > >, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
    >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >,
    std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, std::span<char,
    18446744073709551615ul>)::_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<asio::ip::basic_endpoint<asio::ip::tcp>, std::allocator<asio::ip::basic_endpoint<asio::ip::tcp> >
    >*)::_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<coro_io::ExecutorWrapper<asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >, std::vector<asio::ip::basic_endpoint<asio::ip::tcp>,
    std::allocator<asio::ip::basic_endpoint<asio::ip::tcp> > > >(coro_io::ExecutorWrapper<asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >*, asio::basic_stream_socket<asio::ip::tcp, asio::any_io_executor>&,
    std::vector<asio::ip::basic_endpoint<asio::ip::tcp>, std::allocator<asio::ip::basic_endpoint<asio::ip::tcp> > >
    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==

Activity

  1. qicosmos commented on Jun 10, 2025

    @qicosmos
    Collaborator

    if you build yalantinglibs example with debug, asan chek will be enable, and then you can run the example.
    asan will output the result to tell you if there are some memory problems.

  2. qicosmos commented on Jun 10, 2025

    @qicosmos
    Collaborator

    I think this is a false alarm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions