Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak when using Deno to run trivial JavaScript (Linux) #24575

Closed
matthew-wong1 opened this issue Jul 13, 2024 · 1 comment · Fixed by #24634
Closed

Possible memory leak when using Deno to run trivial JavaScript (Linux) #24575

matthew-wong1 opened this issue Jul 13, 2024 · 1 comment · Fixed by #24634

Comments

@matthew-wong1
Copy link

matthew-wong1 commented Jul 13, 2024

Version: Deno v1.45.2

Might be related to #18369. I compiled Deno from source in Ubuntu 22.04 with address sanitizer enabled, but followed the build guide for the rest of the build steps. I ran: $ RUSTFLAGS=-Zsanitizer=address cargo +nightly build -p deno --bin deno -Zbuild-std --target x86_64-unknown-linux-gnu.

I then created a JS file with just console.log("hello") in it and ran it with $ ./deno run --allow-read --unstable-webgpu --allow-write hello.js

I then got a lot of leak sanitizer warnings (truncated due to length - see file for all warnings). Interestingly, building Deno from source with sanitizers enabled on macOS (Apple Silicon) doesn't produce any Leak Sanitizer errors. Not too sure if this might be a false alarm from leak sanitizer or maybe a Deno compatibility issue with Rust Nightly releases as I know that it's not officially supported.

hello

=================================================================
==69118==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 3248 byte(s) in 203 object(s) allocated from:
    #0 0x556ddcab7ecf in malloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:68:3
    #1 0x556dee917707 in operator new(unsigned long) ../../../../buildtools/third_party/libc++/trunk/src/new.cpp:67:17
    #2 0x556dee8de195 in v8__CFunctionInfo__New ../../../../src/binding.cc:2213:45
    #3 0x556dedf05c6e in v8::fast_api::CFunctionInfo::new::hab2cb194cf4f2bfd /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/v8-0.97.0/src/fast_api.rs:42:28
    #4 0x556dedf05c6e in deno_core::ops::OpCtx::new::h645208597d9f479e /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.293.0/ops.rs:135:9
    #5 0x556dedeffa89 in deno_core::extension_set::create_op_ctxs::h2f875595850bfba6 /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.293.0/extension_set.rs:140:18
    #6 0x556dede869e8 in deno_core::runtime::jsruntime::JsRuntime::new_inner::h64cdee983befa724 /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.293.0/runtime/jsruntime.rs:722:23
    #7 0x556dede83e23 in deno_core::runtime::jsruntime::JsRuntime::try_new::h5a6ef3cb8bdf97bb /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.293.0/runtime/jsruntime.rs:624:5
    #8 0x556dede8392b in deno_core::runtime::jsruntime::JsRuntime::new::hc5c91a8e9bf41542 /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.293.0/runtime/jsruntime.rs:608:11
    #9 0x556de400632f in deno_runtime::worker::MainWorker::from_options::h2ff3b23af1bf08e9 /home/matthew/final_project/deno/runtime/worker.rs:485:26
    #10 0x556de3ffffea in deno_runtime::worker::MainWorker::bootstrap_from_options::he1eb0919b41b8c9a /home/matthew/final_project/deno/runtime/worker.rs:318:22
    #11 0x556ddf059016 in deno::worker::CliMainWorkerFactory::create_custom_worker::_$u7b$$u7b$closure$u7d$$u7d$::h9c75495882ca8200 /home/matthew/final_project/deno/cli/worker.rs:624:22
    #12 0x556ddf052373 in deno::worker::CliMainWorkerFactory::create_main_worker::_$u7b$$u7b$closure$u7d$$u7d$::hb2e867d2ac734487 /home/matthew/final_project/deno/cli/worker.rs:464:8
    #13 0x556ddd77f44d in deno::tools::run::run_script::_$u7b$$u7b$closure$u7d$$u7d$::h752e7137467e653a /home/matthew/final_project/deno/cli/tools/run/mod.rs:73:6
    #14 0x556de0342ba9 in deno::run_subcommand::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hfeaf42a056feb451 /home/matthew/final_project/deno/cli/main.rs:181:82
    #15 0x556de04d12fb in _$LT$futures_util..future..future..map..Map$LT$Fut$C$F$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hebd7cdcfb4b58903 /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.30/src/future/future/map.rs:55:37
    #16 0x556dddeb0010 in _$LT$futures_util..future..future..Map$LT$Fut$C$F$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hcdc5a6f55c8a6778 /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.30/src/lib.rs:91:13
    #17 0x556ddcd41722 in _$LT$core..pin..Pin$LT$P$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h48f0febc6abdbb47 /home/matthew/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:123:9
    #18 0x556dde303963 in tokio::runtime::task::core::Core$LT$T$C$S$GT$::poll::_$u7b$$u7b$closure$u7d$$u7d$::h99985ef5a9fec8fa /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/task/core.rs:328:17
    #19 0x556dde2a8e78 in tokio::loom::std::unsafe_cell::UnsafeCell$LT$T$GT$::with_mut::h82b2bc74139c5519 /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/loom/std/unsafe_cell.rs:16:9
    #20 0x556dde2a8e78 in tokio::runtime::task::core::Core$LT$T$C$S$GT$::poll::h1533b0b6367e160d /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/task/core.rs:317:13
    #21 0x556ddf88994c in tokio::runtime::task::harness::poll_future::_$u7b$$u7b$closure$u7d$$u7d$::hc24c70d35bd0f29e /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/task/harness.rs:485:19
    #22 0x556ddef97cba in _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::ha3fa1c1d10f256c2 /home/matthew/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9
    #23 0x556dde6b56f4 in std::panicking::try::do_call::h6d3c2eda2796e428 /home/matthew/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:553:40
    #24 0x556dde72db0a in __rust_try 6osal7jw6tpru5frqmfpuwbaz
    #25 0x556ddeb96b1c in std::panic::catch_unwind::h29eb2940b1f87297 /home/matthew/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:350:14
    #26 0x556ddf8aebbd in tokio::runtime::task::harness::Harness$LT$T$C$S$GT$::poll_inner::h332f95eb5463882b /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/task/harness.rs:208:27
    #27 0x556ddf95bc88 in tokio::runtime::task::harness::Harness$LT$T$C$S$GT$::poll::h289d431488c263bc /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/task/harness.rs:153:15
    #28 0x556ddd25ad9a in tokio::runtime::task::raw::poll::hc134b5b0dc4b4831 /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/task/raw.rs:271:5
    #29 0x556de9c26f01 in tokio::runtime::task::LocalNotified$LT$S$GT$::run::hcd55b39ee6f2feea /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/task/mod.rs:427:9
    #30 0x556ddfc0fff1 in tokio::runtime::scheduler::current_thread::Context::enter::h1779f6bfe4d4bf36 /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/scheduler/current_thread/mod.rs:404:19
    #31 0x556ddfc15362 in tokio::runtime::scheduler::current_thread::Context::run_task::h8dbf5c679070e9ad /home/matthew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/scheduler/current_thread/mod.rs:343:23

leak_warnings.md

@0f-0b
Copy link
Contributor

0f-0b commented Jul 13, 2024

denoland/deno_core#714 might fix some of the leaks.

bartlomieju added a commit that referenced this issue Jul 22, 2024
Trying out the deno_core patch

Ref denoland/deno_core#832

Closes #24575

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants