opendal icon indicating copy to clipboard operation
opendal copied to clipboard

bug: Memory leak detected in cpp binding CI (LeakSanitizer)

Open KinomotoMio opened this issue 1 year ago • 5 comments

Describe the bug

While running CI tests for the C++ binding in PR #6503, LeakSanitizer reported memory leaks.

part of hdfs_cluster LSan report
2025-08-13T05:09:40.2048639Z =================================================================
2025-08-13T05:09:40.2049214Z ==8047==ERROR: LeakSanitizer: detected memory leaks
2025-08-13T05:09:40.2049582Z 
2025-08-13T05:09:40.2049915Z Direct leak of 503832 byte(s) in 2787 object(s) allocated from:
2025-08-13T05:09:40.2057041Z     #0 0x55c75409d683 in malloc (/home/runner/work/opendal/opendal/bindings/cpp/build/opendal_cpp_test+0x1a2683) (BuildId: 1752b1e55df1c672fed2af1c1a40cccf670994d6)
2025-08-13T05:09:40.2059193Z     #1 0x7f82bf83e4bf in AllocateHeap(unsigned long, MemoryType, AllocFailStrategy::AllocFailEnum) (/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.28-6/x64/lib/server/libjvm.so+0x43e4bf)
2025-08-13T05:09:40.2061485Z     #2 0x7f82c0065669 in ImmutableOopMapSet::build_from(OopMapSet const*) (/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.28-6/x64/lib/server/libjvm.so+0xc65669)
2025-08-13T05:09:40.2063678Z     #3 0x7f82bfa31f12 in CodeBlob::CodeBlob(char const*, CompilerType, CodeBlobLayout const&, CodeBuffer*, int, int, OopMapSet*, bool) (/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.28-6/x64/lib/server/libjvm.so+0x631f12)
2025-08-13T05:09:40.2065375Z     #4 0x7f82bfa8c297 in CompiledMethod::CompiledMethod(Method*, char const*, CompilerType, int, int, CodeBuffer*, int, int, OopMapSet*, bool) (/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.28-6/x64/lib/server/libjvm.so+0x68c297)
2025-08-13T05:09:40.2067139Z     #5 0x7f82c003478c in nmethod::nmethod(Method*, CompilerType, int, int, int, CodeOffsets*, int, DebugInformationRecorder*, Dependencies*, CodeBuffer*, int, OopMapSet*, ExceptionHandlerTable*, ImplicitExceptionTable*, AbstractCompiler*, int, _jobject*, _jobject*) (/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.28-6/x64/lib/server/libjvm.so+0xc3478c)

11_binding_cpp _ ubuntu-latest _ hdfs _ hdfs_cluster.txt

part of monoiofs LSan report
2025-08-13T05:07:03.2798894Z =================================================================
2025-08-13T05:07:03.2799489Z ==7198==ERROR: LeakSanitizer: detected memory leaks
2025-08-13T05:07:03.2799769Z 
2025-08-13T05:07:03.2799985Z Direct leak of 624 byte(s) in 39 object(s) allocated from:
2025-08-13T05:07:03.2808571Z     #0 0x5555c5b6e2e3 in malloc (/home/runner/work/opendal/opendal/bindings/cpp/build/opendal_cpp_test+0x1a92e3) (BuildId: 89023b13fb8a21f8cf6927e999036acdef5e2d36)
2025-08-13T05:07:03.2810131Z     #1 0x5555c600ebae in alloc::alloc::alloc::hc8dcb7ce11349a10 /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/alloc.rs:94:9
2025-08-13T05:07:03.2811617Z     #2 0x5555c600ebae in alloc::alloc::Global::alloc_impl::h261e52c6291fe15f /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/alloc.rs:189:73
2025-08-13T05:07:03.2813064Z     #3 0x5555c600ebae in _$LT$alloc..alloc..Global$u20$as$u20$core..alloc..Allocator$GT$::allocate::heff4d61c28958be1 /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/alloc.rs:250:14
2025-08-13T05:07:03.2814829Z     #4 0x5555c600ebae in alloc::alloc::exchange_malloc::h7e2bceb9247f6c38 /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/alloc.rs:351:18
2025-08-13T05:07:03.2816553Z     #5 0x5555c600ebae in alloc::boxed::Box$LT$T$GT$::new::h30a0290c6bdd8198 /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/boxed.rs:261:16
2025-08-13T05:07:03.2818817Z     #6 0x5555c600ebae in monoio::driver::uring::IoUringDriver::new_with_entries::h351fa749fad67100 /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/monoio-0.2.4/src/driver/uring/mod.rs:157:33

12_binding_cpp _ ubuntu-latest _ monoiofs _ monoiofs.txt

Steps to Reproduce

  • Trigger GitHub Actions CI for the C++ bindings (default matrix).
  • Check the job logs.

Expected Behavior

  • No memory leaks reported by LeakSanitizer.
  • CI passes without leak-related failures.

Additional Context

Related to PR #6503 and issue #6250

Are you willing to submit a PR to fix this bug?

  • [ ] Yes, I would like to submit a PR.

KinomotoMio avatar Aug 14 '25 03:08 KinomotoMio

Hi @KinomotoMio! I'm Dosu and I’m helping the opendal team.

LeakSanitizer is reporting memory leaks in the C++ binding CI for both HDFS and monoiofs. The HDFS leak traces back to the JVM (libjvm.so), suggesting the leak may originate from Java integration or JNI usage, not directly from OpenDAL's C++ or Rust code. The monoiofs leak is traced into Rust's alloc crate and the monoio driver, which aligns with previous findings that some memory leaks in monoiofs are either expected or considered acceptable trade-offs by maintainers and are not classified as critical bugs (see discussion).

There are no existing issues or discussions specifically about LeakSanitizer-detected memory leaks in the C++ bindings, HDFS, or monoiofs. This appears to be a newly surfaced issue in the context of PR #6503. If you need to investigate further, focus on recent changes in FFI/JNI resource management and consider whether the leaks are reproducible outside CI or are artifacts of integration with external dependencies.

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about opendal with Dosu Add Dosu to your team

dosubot[bot] avatar Aug 14 '25 03:08 dosubot[bot]

Should we temporarily skip these two failing C++ binding tests in CI until the memory leak is resolved?

KinomotoMio avatar Aug 14 '25 03:08 KinomotoMio

now ignore it.

asukaminato0721 avatar Aug 14 '25 23:08 asukaminato0721

Hi, why this issue has been closed? They are not bugs anymore?

Xuanwo avatar Aug 14 '25 23:08 Xuanwo

Hi, why this issue has been closed? They are not bugs anymore?

https://github.com/apache/opendal/pull/6503/files

yes, all the CI passed, and no memory leak now.

asukaminato0721 avatar Aug 15 '25 01:08 asukaminato0721