brpc在 arm64环境 使用 valgrind会显示 很多内存 泄漏,

Offen
#2,957 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
30/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
cpp
Bereich
backend

Rechercherichtung

Beginne mit den gemeldeten arm64-Valgrind-Traces bei bthread::id_create_impl, bthread::TaskGroup::init, bthread::WorkStealingQueue::init und butil::iobuf::acquire_tls_block(). Reproduziere das Speicherwachstum und vergleiche das Verhalten mit und ohne tcmalloc; abgeschlossen ist die Aufgabe, wenn das relevante Leck oder die Interaktion mit dem Allocator identifiziert wurde und bestätigt ist, dass der arm64-Prozess nicht mehr wächst, bis er mit OOM endet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug
brpc在 arm64环境 内存 快速增长 后oom, 使用 valgrind会显示 很多内存 泄漏, 不确定 是 哪儿 的 问题, 另外就是 如果 加上 tcmalloc后, 就不会一直内存增长

To Reproduce

Expected behavior

Versions
OS: Linux xxx 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 16:08:13 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

Compiler: gcc10
brpc:brpc-1.10.0
protobuf:

Additional context/screenshots

==301== 872,576 (35,904 direct, 836,672 indirect) bytes in 17 blocks are definitely lost in loss record 1,911 of 1,927
==301== at 0x4866554: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==301== by 0x51CA47: bthread::id_create_impl(bthread_id_t*, void*, int ()(bthread_id_t, void, int), int ()(bthread_id_t, void, int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)) (in /app/bin/visioncloud_gateway)
==301== by 0x51CB47: bthread_id_create (in /app/bin/visioncloud_gateway)
==301== by 0x3AC86F: brpc::Socket::OnCreated(brpc::SocketOptions const&) (in /app/bin/visioncloud_gateway)
==301== by 0x3B5123: int brpc::VersionedRefWithIdbrpc::Socket::Createbrpc::SocketOptions(unsigned long*, brpc::SocketOptions) (in /app/bin/visioncloud_gateway)
==301== by 0x3ACEDF: brpc::Socket::Create(brpc::SocketOptions const&, unsigned long*) (in /app/bin/visioncloud_gateway)
==301== by 0x462787: brpc::Acceptor::OnNewConnectionsUntilEAGAIN(brpc::Socket*) (in /app/bin/visioncloud_gateway)
==301== by 0x462D83: brpc::Acceptor::OnNewConnections(brpc::Socket*) (in /app/bin/visioncloud_gateway)
==301== by 0x3A9083: brpc::Socket::ProcessEvent(void*) (in /app/bin/visioncloud_gateway)
==301== by 0x50A4D3: bthread::TaskGroup::task_runner(long) (in /app/bin/visioncloud_gateway)
==301== by 0x50AB2F: bthread::TaskGroup::run_main_task() (in /app/bin/visioncloud_gateway)
==301== by 0x5118CF: bthread::TaskControl::worker_thread(void*) (in /app/bin/visioncloud_gateway)
==301==
==301== 1,015,064 (3,480 direct, 1,011,584 indirect) bytes in 145 blocks are definitely lost in loss record 1,912 of 1,927
==301== at 0x4866058: operator new(unsigned long, std::nothrow_t const&) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==301== by 0x5AE187: butil::detail::get_or_new_thread_exit_helper() (in /app/bin/visioncloud_gateway)
==301== by 0x5AE207: butil::thread_atexit(void ()(void), void*) (in /app/bin/visioncloud_gateway)
==301== by 0x509C2B: bthread::TaskGroup::init(unsigned long) (in /app/bin/visioncloud_gateway)
==301== by 0x50F1E7: bthread::TaskControl::create_group(int) (in /app/bin/visioncloud_gateway)
==301== by 0x511723: bthread::TaskControl::worker_thread(void*) (in /app/bin/visioncloud_gateway)
==301== by 0x50AD5B7: start_thread (pthread_create.c:442)
==301== by 0x5115EDB: thread_start (clone.S:79)
==301==
==301== 2,179,072 bytes in 133 blocks are definitely lost in loss record 1,920 of 1,927
==301== at 0x4865058: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==301== by 0x50994F: bthread::TaskGroup::init(unsigned long) (in /app/bin/visioncloud_gateway)
==301== by 0x50F1E7: bthread::TaskControl::create_group(int) (in /app/bin/visioncloud_gateway)
==301== by 0x511723: bthread::TaskControl::worker_thread(void*) (in /app/bin/visioncloud_gateway)
==301== by 0x50AD5B7: start_thread (pthread_create.c:442)
==301== by 0x5115EDB: thread_start (clone.S:79)
==301==
==301== 4,423,680 bytes in 135 blocks are definitely lost in loss record 1,923 of 1,927
==301== at 0x4867388: operator new[](unsigned long, std::nothrow_t const&) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==301== by 0x50B99F: bthread::WorkStealingQueue::init(unsigned long) (in /app/bin/visioncloud_gateway)
==301== by 0x50993F: bthread::TaskGroup::init(unsigned long) (in /app/bin/visioncloud_gateway)
==301== by 0x50F1E7: bthread::TaskControl::create_group(int) (in /app/bin/visioncloud_gateway)
==301== by 0x511723: bthread::TaskControl::worker_thread(void*) (in /app/bin/visioncloud_gateway)
==301== by 0x50AD5B7: start_thread (pthread_create.c:442)
==301== by 0x5115EDB: thread_start (clone.S:79)
==301==
==301== 13,746,176 (376,832 direct, 13,369,344 indirect) bytes in 46 blocks are definitely lost in loss record 1,926 of 1,927
==301== at 0x4865058: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==301== by 0x5A260F: butil::iobuf::acquire_tls_block() (in /app/bin/visioncloud_gateway)
==301== by 0x5A3773: butil::IOPortal::pappend_from_file_descriptor(int, long, unsigned long) (in /app/bin/visioncloud_gateway)
==301== by 0x3A6723: brpc::Socket::DoRead(unsigned long) (in /app/bin/visioncloud_gateway)
==301== by 0x3E75DF: brpc::InputMessenger::OnNewMessages(brpc::Socket*) (in /app/bin/visioncloud_gateway)
==301== by 0x3A9083: brpc::Socket::ProcessEvent(void*) (in /app/bin/visioncloud_gateway)
==301== by 0x50A4D3: bthread::TaskGroup::task_runner(long) (in /app/bin/visioncloud_gateway)
==301== by 0x50AB2F: bthread::TaskGroup::run_main_task() (in /app/bin/visioncloud_gateway)
==301== by 0x5118CF: bthread::TaskControl::worker_thread(void*) (in /app/bin/visioncloud_gateway)
==301== by 0x50AD5B7: start_thread (pthread_create.c:442)
==301== by 0x5115EDB: thread_start (clone.S:79)
==301==
==301== LEAK SUMMARY:
==301== definitely lost: 8,546,672 bytes in 4,651 blocks
==301== indirectly lost: 17,290,390 bytes in 2,683 blocks
==301== possibly lost: 485,305 bytes in 258 blocks
==301== still reachable: 44,379,389 bytes in 6,286 blocks
==301== of which reachable via heuristic:
==301== newarray : 3,656 bytes in 2 blocks
==301== suppressed: 0 bytes in 0 blocks
==301== Reachable blocks (those to which a pointer was found) are not shown.
==301== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==301==
==301== Use --track-origins=yes to see where uninitialised values come from
==301== For lists of detected and suppressed errors, rerun with: -s
==301== ERROR SUMMARY: 171162 errors from 1164 contexts (suppressed: 0 from 0)
root@visioncloud-gateway-d5c95b555-xjjc5:/app#
root@visioncloud-gateway-d5c95b555-xjjc5:/app# ==301== 13,746,176 (376,832 direct, 13,369,344 indirect) bytes in 46 blocks are definitely lost in loss record 1,926 of 1,927
==301== at 0x4865058: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==301== by 0x5A260F: butil::iobuf::acquire_tls_block() (in /app/bin/visioncloud_gateway)
==301== by 0x5A3773: butil::IOPortal::pappend_from_file_descriptor(int, long, unsigned long) (in /app/bin/visioncloud_gateway)
==301== by 0x3A6723: brpc::Socket::DoRead(unsigned long) (in /app/bin/visioncloud_gateway)
==301== by 0x3E75DF: brpc::InputMessenger::OnNewMessages(brpc::Socket*) (in /app/bin/visioncloud_gateway)
==301== by 0x3A9083: brpc::Socket::ProcessEvent(void*) (in /app/bin/visioncloud_gateway)
==301== by 0x50A4D3: bthread::TaskGroup::task_runner(long) (in /app/bin/visioncloud_gateway)
==301== by 0x50AB2F: bthread::TaskGroup::run_main_task() (in /app/bin/visioncloud_gateway)
==301== by 0x5118CF: bthread::TaskControl::worker_thread(void*) (in /app/bin/visioncloud_gateway)
==301== by 0x50AD5B7: start_thread (pthread_create.c:442)
==301== by 0x5115EDB: thread_start (clone.S:79)

Vorherrschende Sprache
C++
Sterne
17.6k
Forks
4.2k
Ø Merge
3 T. 17 Std.
Gemergte PRs (30 T.)
72

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus apache/brpc

Alle Issues in apache/brpc

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.