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

Very small memory leaks reported by LeakSanitizer when testing multiple files #330

Closed
qarmin opened this issue Dec 8, 2024 · 3 comments
Closed

Comments

@qarmin
Copy link

qarmin commented Dec 8, 2024

Oxlint - 02f9903211bd8b8ea745704cd651c8f7616255c1

I got several small memory leaks, when executing command

oxlint -D all -D nursery --import-plugin --jsdoc-plugin --jest-plugin --vitest-plugin --jsx-a11y-plugin --nextjs-plugin --react-perf-plugin FOLDER_TO_TEST --fix --fix-suggestions --fix-dangerously

in CI with ~1000 files at once

sadly there is no reproduction project yet, because my fuzzer is not designed to catch issues that happens with more than one file - but I will try to create such project.

example of leak

Direct leak of 432 byte(s) in 3 object(s) allocated from:
    #0 0x561c330fe8df in malloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:68:3
    oxc-project/oxc#1 0x561c335af66b in alloc::alloc::alloc::hda39ecc0318c2468 /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:99:9
    oxc-project/oxc#2 0x561c335af66b in alloc::alloc::Global::alloc_impl::h7ce9227b5757320e /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:195:73
    oxc-project/oxc#3 0x561c335af66b in _$LT$alloc..alloc..Global$u20$as$u20$core..alloc..Allocator$GT$::allocate::h06f332da5a74f263 /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:257:9
    oxc-project/oxc#4 0x561c335af66b in alloc::alloc::exchange_malloc::h3d4642dd947c6a98 /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:352:18
    oxc-project/oxc#5 0x561c335af66b in alloc::boxed::Box$LT$T$GT$::new::ha4f8649d34c5ecd3 /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:254:9
    #6 0x561c335af66b in alloc::sync::Arc$LT$T$GT$::new::h5ae437f1cb23f5af /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:391:25
    #7 0x561c335af66b in oxc_resolver::cache::Cache$LT$Fs$GT$::value::hfed8ec6548af329c /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/cache.rs:54:31
    #8 0x561c336112b2 in oxc_resolver::cache::CachedPath::add_extension::_$u7b$$u7b$closure$u7d$$u7d$::hc5c667472fe78ba9 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/cache.rs:324:13
    oxc-project/oxc#9 0x561c336112b2 in std::thread::local::LocalKey$LT$T$GT$::try_with::h5875916aa2506532 /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:308:12
    oxc-project/oxc#10 0x561c336112b2 in std::thread::local::LocalKey$LT$T$GT$::with::he29c4d2ab9c59644 /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:272:9
    oxc-project/oxc#11 0x561c336112b2 in oxc_resolver::cache::CachedPath::add_extension::hccbbcbb454ecade9 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/cache.rs:317:22
    oxc-project/oxc#12 0x561c336112b2 in oxc_resolver::ResolverGeneric$LT$Fs$GT$::load_extensions::h6c6a02b5a28a98b6 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/lib.rs:598:36
    oxc-project/oxc#13 0x561c3360f28d in oxc_resolver::ResolverGeneric$LT$Fs$GT$::load_as_file::h5fb4cf9e1848af55 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/lib.rs:530:29
    oxc-project/oxc#14 0x561c33619ecb in oxc_resolver::ResolverGeneric$LT$Fs$GT$::load_as_file_or_directory::h9b687bb2993d4d8b /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/lib.rs:576:33
    oxc-project/oxc#15 0x561c33612dee in oxc_resolver::ResolverGeneric$LT$Fs$GT$::require_relative::haf25cfc10cce3fb0 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/lib.rs:401:29
    oxc-project/oxc#16 0x561c33615b5c in oxc_resolver::ResolverGeneric$LT$Fs$GT$::require_without_parse::hd636d7dd456f47db /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/lib.rs:311:17
    oxc-project/oxc#17 0x561c3361f924 in oxc_resolver::ResolverGeneric$LT$Fs$GT$::require::h9e752dc7f3f45391 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/lib.rs:285:9
    #18 0x561c33620300 in oxc_resolver::ResolverGeneric$LT$Fs$GT$::resolve_impl::he46a85178977ed82 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/lib.rs:248:27
    oxc-project/oxc#19 0x561c33620300 in oxc_resolver::ResolverGeneric$LT$Fs$GT$::resolve_tracing::h46d43630fa557313 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/lib.rs:228:17
    oxc-project/oxc#20 0x561c33620300 in oxc_resolver::ResolverGeneric$LT$Fs$GT$::resolve::hb3f4ebea4be397ea /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/oxc_resolver-2.1.1/src/lib.rs:177:9
    oxc-project/oxc#21 0x561c336d7676 in oxc_linter::service::runtime::Runtime::process_source::_$u7b$$u7b$closure$u7d$$u7d$::hb5b01d1c657ec3fc /home/runner/work/Automated-Fuzzer/Automated-Fuzzer/oxc-main/crates/oxc_linter/src/service/runtime.rs:247:21

Looks that Cache from oxc-resolver can generate this leak(but this could be also a false positive)

pub struct Cache<Fs> {
pub(crate) fs: Fs,
paths: DashSet<CachedPath, BuildHasherDefault<IdentityHasher>>,
tsconfigs: DashMap<PathBuf, Arc<TsConfig>, BuildHasherDefault<FxHasher>>,
}

full leak info:
leaks.txt

@Boshen Boshen transferred this issue from oxc-project/oxc Dec 8, 2024
@Boshen
Copy link
Member

Boshen commented Dec 8, 2024

TODO: setup miri.

Very probable that this comes from dashmap :-/

@Boshen
Copy link
Member

Boshen commented Dec 14, 2024

Tried in #351

There's definitely a small leak in

pub static SCRATCH_PATH: RefCell<PathBuf> = RefCell::new(PathBuf::with_capacity(256));

But I don't know how to fix it :-/

@Boshen
Copy link
Member

Boshen commented Dec 14, 2024

Close as not planned until I learn something new about this.

@Boshen Boshen closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2024
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

No branches or pull requests

2 participants