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

potential memory leak in backtrace #69721

Closed
mimoo opened this issue Mar 4, 2020 · 2 comments
Closed

potential memory leak in backtrace #69721

mimoo opened this issue Mar 4, 2020 · 2 comments
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@mimoo
Copy link

mimoo commented Mar 4, 2020

Yellow!

I've been investigating a memory leak that we found via LeakSanitizer. The thing looked like this:

click here
==86445==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2853 byte(s) in 80 object(s) allocated from:
#0 0x559896d2b9ed in malloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cc:145:3
#1 0x5598ae1c0ef2 in __rdos_backtrace_alloc (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70fef2)
#2 0x5598ae1c5e36 in read_line_info (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e714e36)
#3 0x5598ae1c4df0 in dwarf_lookup_pc (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e713df0)
#4 0x5598ae1c2cdf in dwarf_fileline (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e711cdf)
#5 0x5598ae1bc506 in backtrace::symbolize::libbacktrace::syminfo_cb::h4645a25390a5567b /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/symbolize/libbacktrace.rs:189:8
#6 0x5598ae1bf20b in elf_syminfo (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70e20b)
#7 0x5598ae1bcb82 in __rdos_backtrace_syminfo (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70bb82)
#8 0x5598ae1bc6ab in backtrace::symbolize::libbacktrace::resolve::hef1bf34e465712ca /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/symbolize/libbacktrace.rs:469:8
#9 0x5598ae188861 in backtrace::symbolize::resolve_frame_unsynchronized::h64576c15b6f0d017 /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/symbolize/mod.rs:178:4
#10 0x5598ae188861 in std::backtrace::Capture::resolve::h12b3b1574c5326e4 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/backtrace.rs:397:16
#11 0x5598ae188861 in $LT$std..backtrace..Backtrace$u20$as$u20$core..fmt..Display$GT$::fmt::h9238db13fc40cf16 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/backtrace.rs:339:8
#12 0x5598ac3feb1c in $LT$$RF$T$u20$as$u20$core..fmt..Display$GT$::fmt::h9b038eb6aa0ab6ad /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1949:80
#13 0x5598ae1dc44b in core::fmt::write::h74f862b8fe5295c5 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1053:16
#14 0x5598ac3f2385 in core::fmt::Write::write_fmt::h5619abe06b01e135 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:195:8
#15 0x5598ac3ff02b in $LT$T$u20$as$u20$alloc..string..ToString$GT$::to_string::h711ce6a45b96d0ff /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/liballoc/string.rs:2165:8
#16 0x5598ac3dc56b in anyhow::fmt::
$LT$impl$u20$anyhow..error..ErrorImpl$LT$$LP$$RP$$GT$$GT$::debug::hc0a884696ea7f686 /home/davidwg/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.26/src/fmt.rs:47:36
#17 0x5598ac3ec366 in anyhow::error::
$LT$impl$u20$core..fmt..Debug$u20$for$u20$anyhow..Error$GT$::fmt::h9d6bac8d0df90610 /home/davidwg/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.26/src/error.rs:492:8
#18 0x5598a4400dac in $LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$::fmt::hd157e7bb0a137d52 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1949:80
#19 0x5598ae1dc44b in core::fmt::write::h74f862b8fe5295c5 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1053:16
#20 0x5598ae1cf7c2 in core::fmt::Write::write_fmt::h9faa23917d9c1261 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:195:8
#21 0x5598ae1cf7c2 in alloc::fmt::format::hd31ca1f26e46e32c /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/liballoc/fmt.rs:571:4
#22 0x55989dbdd721 in libra_logger::security::SecurityLog::error::hb6b81fe85beddef7 /home/davidwg/libra/<::alloc::macros::format macros>:4:18
#23 0x559896e6dbb8 in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::sync_up::
$u7b$$u7b$closure$u7d$$u7d$::
$u7b$$u7b$closure$u7d$$u7d$::hf2e2c248928ca891 /home/davidwg/libra/consensus/src/chained_bft/event_process
or.rs:426:12
#24 0x5598972ba98f in core::result::Result$LT$T$C$E$GT$::map_err::h26aaa04a741c110a /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/result.rs:610:26
#25 0x559896e7ac03 in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::sync_up::_$u7b$$u7b$closure$u7d$$u7d$::hddc8eb4cdebca996 /home/davidwg/libra/consensus/src/chained_bft/event_processor.rs:425:8
#26 0x5598975e9e9d in $LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hd8f929e8a92f042c /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:44:14
#27 0x559897597859 in std::future::poll_with_tls_context::h5b201fc4d3347663 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:102:13
#28 0x559896e66f1a in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::pre_process_proposal::
$u7b$$u7b$closure$u7d$$u7d$::he3b9ca33e6096ef1 /home/davidwg/libra/consensus/src/chained_bft/event_processor.rs:341:24
#29 0x5598975e6833 in $LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hca38850150e4ce63 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:44:14
#30 0x5598975939e3 in std::future::poll_with_tls_context::h42f38171f79b3cb9 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:102:13
#31 0x559896e5cd9f in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::process_proposal_msg::
$u7b$$u7b$closure$u7d$$u7d$::hb98b4b771a9658f0 /home/davidwg/libra/consensus/src/chained_bft/event_processor.rs:310:29

Direct leak of 2760 byte(s) in 23 object(s) allocated from:
#0 0x559896d2b9ed in malloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cc:145:3
#1 0x5598ae1c0ef2 in __rdos_backtrace_alloc (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70fef2)
#2 0x5598ae1c2496 in __rdos_backtrace_dwarf_add (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e711496)
#3 0x5598ae1bf01b in elf_add (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70e01b)
#4 0x5598ae1bf14b in phdr_callback (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70e14b)
#5 0x7f1bad0e742b in __dl_iterate_phdr (/lib64/libc.so.6+0x13c42b)
#6 0x5598ae1bcf4a in __rdos_backtrace_initialize (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70bf4a)
#7 0x5598ae1bcaee in fileline_initialize (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70baee)
#8 0x5598ae1bcb62 in __rdos_backtrace_syminfo (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70bb62)
#9 0x5598ae1bc6ab in backtrace::symbolize::libbacktrace::resolve::hef1bf34e465712ca /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/symbolize/libbacktrace.rs:469:8
#10 0x5598ae188861 in backtrace::symbolize::resolve_frame_unsynchronized::h64576c15b6f0d017 /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/symbolize/mod.rs:178:4
#11 0x5598ae188861 in std::backtrace::Capture::resolve::h12b3b1574c5326e4 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/backtrace.rs:397:16
#12 0x5598ae188861 in $LT$std..backtrace..Backtrace$u20$as$u20$core..fmt..Display$GT$::fmt::h9238db13fc40cf16 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/backtrace.rs:339:8
#13 0x5598ac3feb1c in $LT$$RF$T$u20$as$u20$core..fmt..Display$GT$::fmt::h9b038eb6aa0ab6ad /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1949:80
#14 0x5598ae1dc44b in core::fmt::write::h74f862b8fe5295c5 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1053:16
#15 0x5598ac3f2385 in core::fmt::Write::write_fmt::h5619abe06b01e135 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:195:8
#16 0x5598ac3ff02b in $LT$T$u20$as$u20$alloc..string..ToString$GT$::to_string::h711ce6a45b96d0ff /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/liballoc/string.rs:2165:8
#17 0x5598ac3dc56b in anyhow::fmt::
$LT$impl$u20$anyhow..error..ErrorImpl$LT$$LP$$RP$$GT$$GT$::debug::hc0a884696ea7f686 /home/davidwg/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.26/src/fmt.rs:47:36
#18 0x5598ac3ec366 in anyhow::error::
$LT$impl$u20$core..fmt..Debug$u20$for$u20$anyhow..Error$GT$::fmt::h9d6bac8d0df90610 /home/davidwg/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.26/src/error.rs:492:8
#19 0x5598a4400dac in $LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$::fmt::hd157e7bb0a137d52 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1949:80
#20 0x5598ae1dc44b in core::fmt::write::h74f862b8fe5295c5 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1053:16
#21 0x5598ae1cf7c2 in core::fmt::Write::write_fmt::h9faa23917d9c1261 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:195:8
#22 0x5598ae1cf7c2 in alloc::fmt::format::hd31ca1f26e46e32c /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/liballoc/fmt.rs:571:4
#23 0x55989dbdd721 in libra_logger::security::SecurityLog::error::hb6b81fe85beddef7 /home/davidwg/libra/<::alloc::macros::format macros>:4:18
#24 0x559896e6dbb8 in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::sync_up::
$u7b$$u7b$closure$u7d$$u7d$::
$u7b$$u7b$closure$u7d$$u7d$::hf2e2c248928ca891 /home/davidwg/libra/consensus/src/chained_bft/event_process
or.rs:426:12
#25 0x5598972ba98f in core::result::Result$LT$T$C$E$GT$::map_err::h26aaa04a741c110a /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/result.rs:610:26
#26 0x559896e7ac03 in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::sync_up::_$u7b$$u7b$closure$u7d$$u7d$::hddc8eb4cdebca996 /home/davidwg/libra/consensus/src/chained_bft/event_processor.rs:425:8
#27 0x5598975e9e9d in $LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hd8f929e8a92f042c /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:44:14
#28 0x559897597859 in std::future::poll_with_tls_context::h5b201fc4d3347663 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:102:13
#29 0x559896e66f1a in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::pre_process_proposal::
$u7b$$u7b$closure$u7d$$u7d$::he3b9ca33e6096ef1 /home/davidwg/libra/consensus/src/chained_bft/event_processor.rs:341:24
#30 0x5598975e6833 in $LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hca38850150e4ce63 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:44:14
#31 0x5598975939e3 in std::future::poll_with_tls_context::h42f38171f79b3cb9 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:102:13
Indirect leak of 10144 byte(s) in 23 object(s) allocated from:
#0 0x559896d2b9ed in malloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cc:145:3
#1 0x5598ae1c0ef2 in __rdos_backtrace_alloc (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70fef2)
#2 0x5598ae1c1978 in __rdos_backtrace_dwarf_add (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e710978)
#3 0x5598ae1bf01b in elf_add (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70e01b)
#4 0x5598ae1bf14b in phdr_callback (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70e14b)
#5 0x7f1bad0e742b in __dl_iterate_phdr (/lib64/libc.so.6+0x13c42b)
#6 0x5598ae1bcf4a in __rdos_backtrace_initialize (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70bf4a)
#7 0x5598ae1bcaee in fileline_initialize (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70baee)
#8 0x5598ae1bcb62 in __rdos_backtrace_syminfo (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70bb62)
#9 0x5598ae1bc6ab in backtrace::symbolize::libbacktrace::resolve::hef1bf34e465712ca /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/symbolize/libbacktrace.rs:469:8
#10 0x5598ae188861 in backtrace::symbolize::resolve_frame_unsynchronized::h64576c15b6f0d017 /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/symbolize/mod.rs:178:4
#11 0x5598ae188861 in std::backtrace::Capture::resolve::h12b3b1574c5326e4 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/backtrace.rs:397:16
#12 0x5598ae188861 in $LT$std..backtrace..Backtrace$u20$as$u20$core..fmt..Display$GT$::fmt::h9238db13fc40cf16 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/backtrace.rs:339:8
#13 0x5598ac3feb1c in $LT$$RF$T$u20$as$u20$core..fmt..Display$GT$::fmt::h9b038eb6aa0ab6ad /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1949:80
#14 0x5598ae1dc44b in core::fmt::write::h74f862b8fe5295c5 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1053:16
#15 0x5598ac3f2385 in core::fmt::Write::write_fmt::h5619abe06b01e135 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:195:8
#16 0x5598ac3ff02b in $LT$T$u20$as$u20$alloc..string..ToString$GT$::to_string::h711ce6a45b96d0ff /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/liballoc/string.rs:2165:8
#17 0x5598ac3dc56b in anyhow::fmt::
$LT$impl$u20$anyhow..error..ErrorImpl$LT$$LP$$RP$$GT$$GT$::debug::hc0a884696ea7f686 /home/davidwg/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.26/src/fmt.rs:47:36
#18 0x5598ac3ec366 in anyhow::error::
$LT$impl$u20$core..fmt..Debug$u20$for$u20$anyhow..Error$GT$::fmt::h9d6bac8d0df90610 /home/davidwg/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.26/src/error.rs:492:8
#19 0x5598a4400dac in $LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$::fmt::hd157e7bb0a137d52 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1949:80
#20 0x5598ae1dc44b in core::fmt::write::h74f862b8fe5295c5 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1053:16
#21 0x5598ae1cf7c2 in core::fmt::Write::write_fmt::h9faa23917d9c1261 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:195:8
#22 0x5598ae1cf7c2 in alloc::fmt::format::hd31ca1f26e46e32c /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/liballoc/fmt.rs:571:4
#23 0x55989dbdd721 in libra_logger::security::SecurityLog::error::hb6b81fe85beddef7 /home/davidwg/libra/<::alloc::macros::format macros>:4:18
#24 0x559896e6dbb8 in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::sync_up::
$u7b$$u7b$closure$u7d$$u7d$::
$u7b$$u7b$closure$u7d$$u7d$::hf2e2c248928ca891 /home/davidwg/libra/consensus/src/chained_bft/event_process
or.rs:426:12
#25 0x5598972ba98f in core::result::Result$LT$T$C$E$GT$::map_err::h26aaa04a741c110a /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/result.rs:610:26
#26 0x559896e7ac03 in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::sync_up::
$u7b$$u7b$closure$u7d$$u7d$::hddc8eb4cdebca996 /home/davidwg/libra/consensus/src/chained_bft/event_processor.rs:425:8
#27 0x5598975e9e9d in $LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hd8f929e8a92f042c /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:44:14
#28 0x559897597859 in std::future::poll_with_tls_context::h5b201fc4d3347663 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:102:13
#29 0x559896e66f1a in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::pre_process_proposal::
$u7b$$u7b$closure$u7d$$u7d$::he3b9ca33e6096ef1 /home/davidwg/libra/consensus/src/chained_bft/event_processor.rs:341:24
#30 0x5598975e6833 in _$LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hca38850150e4ce63 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:44:14
#31 0x5598975939e3 in std::future::poll_with_tls_context::h42f38171f79b3cb9 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:102:13

Indirect leak of 8296 byte(s) in 307 object(s) allocated from:
#0 0x559896d2b9ed in malloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cc:145:3
#1 0x5598ae1c0ef2 in __rdos_backtrace_alloc (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70fef2)
#2 0x5598ae1c1e7c in __rdos_backtrace_dwarf_add (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e710e7c)
#3 0x5598ae1bf01b in elf_add (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70e01b)
#4 0x5598ae1bf14b in phdr_callback (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70e14b)
#5 0x7f1bad0e742b in __dl_iterate_phdr (/lib64/libc.so.6+0x13c42b)
#6 0x5598ae1bcf4a in __rdos_backtrace_initialize (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70bf4a)
#7 0x5598ae1bcaee in fileline_initialize (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70baee)
#8 0x5598ae1bcb62 in __rdos_backtrace_syminfo (/home/davidwg/libra/target/x86_64-unknown-linux-gnu/debug/fuzz_runner+0x1e70bb62)
#9 0x5598ae1bc6ab in backtrace::symbolize::libbacktrace::resolve::hef1bf34e465712ca /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/symbolize/libbacktrace.rs:469:8
#10 0x5598ae188861 in backtrace::symbolize::resolve_frame_unsynchronized::h64576c15b6f0d017 /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/symbolize/mod.rs:178:4
#11 0x5598ae188861 in std::backtrace::Capture::resolve::h12b3b1574c5326e4 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/backtrace.rs:397:16
#12 0x5598ae188861 in $LT$std..backtrace..Backtrace$u20$as$u20$core..fmt..Display$GT$::fmt::h9238db13fc40cf16 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/backtrace.rs:339:8
#13 0x5598ac3feb1c in $LT$$RF$T$u20$as$u20$core..fmt..Display$GT$::fmt::h9b038eb6aa0ab6ad /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1949:80
#14 0x5598ae1dc44b in core::fmt::write::h74f862b8fe5295c5 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1053:16
#15 0x5598ac3f2385 in core::fmt::Write::write_fmt::h5619abe06b01e135 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:195:8
#16 0x5598ac3ff02b in $LT$T$u20$as$u20$alloc..string..ToString$GT$::to_string::h711ce6a45b96d0ff /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/liballoc/string.rs:2165:8
#17 0x5598ac3dc56b in anyhow::fmt::
$LT$impl$u20$anyhow..error..ErrorImpl$LT$$LP$$RP$$GT$$GT$::debug::hc0a884696ea7f686 /home/davidwg/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.26/src/fmt.rs:47:36
#18 0x5598ac3ec366 in anyhow::error::
$LT$impl$u20$core..fmt..Debug$u20$for$u20$anyhow..Error$GT$::fmt::h9d6bac8d0df90610 /home/davidwg/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.26/src/error.rs:492:8
#19 0x5598a4400dac in $LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$::fmt::hd157e7bb0a137d52 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1949:80
#20 0x5598ae1dc44b in core::fmt::write::h74f862b8fe5295c5 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:1053:16
#21 0x5598ae1cf7c2 in core::fmt::Write::write_fmt::h9faa23917d9c1261 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/fmt/mod.rs:195:8
#22 0x5598ae1cf7c2 in alloc::fmt::format::hd31ca1f26e46e32c /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/liballoc/fmt.rs:571:4
#23 0x55989dbdd721 in libra_logger::security::SecurityLog::error::hb6b81fe85beddef7 /home/davidwg/libra/<::alloc::macros::format macros>:4:18
#22 0x5598ae1cf7c2 in alloc::fmt::format::hd31ca1f26e46e32c /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/liballoc/fmt.rs:571:4
#23 0x55989dbdd721 in libra_logger::security::SecurityLog::error::hb6b81fe85beddef7 /home/davidwg/libra/<::alloc::macros::format macros>:4:18
#24 0x559896e6dbb8 in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::sync_up::
$u7b$$u7b$closure$u7d$$u7d$::
$u7b$$u7b$closure$u7d$$u7d$::hf2e2c248928ca891 /home/davidwg/libra/consensus/src/chained_bft/event_process
or.rs:426:12
#25 0x5598972ba98f in core::result::Result$LT$T$C$E$GT$::map_err::h26aaa04a741c110a /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libcore/result.rs:610:26
#26 0x559896e7ac03 in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::sync_up::_$u7b$$u7b$closure$u7d$$u7d$::hddc8eb4cdebca996 /home/davidwg/libra/consensus/src/chained_bft/event_processor.rs:425:8
#27 0x5598975e9e9d in $LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hd8f929e8a92f042c /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:44:14
#28 0x559897597859 in std::future::poll_with_tls_context::h5b201fc4d3347663 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:102:13
#29 0x559896e66f1a in consensus::chained_bft::event_processor::EventProcessor$LT$T$GT$::pre_process_proposal::
$u7b$$u7b$closure$u7d$$u7d$::he3b9ca33e6096ef1 /home/davidwg/libra/consensus/src/chained_bft/event_processor.rs:341:24
#30 0x5598975e6833 in _$LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hca38850150e4ce63 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:44:14
#31 0x5598975939e3 in std::future::poll_with_tls_context::h42f38171f79b3cb9 /rustc/abc3073c92df034636a823c5382ece2186d22b9e/src/libstd/future.rs:102:13

SUMMARY: AddressSanitizer: 24053 byte(s) leaked in 433 allocation(s).

Digging a bit, it seems like this simple script leaks according to valgrind:

#![feature(backtrace)]
use std::backtrace::Backtrace;
fn main() {
    for _ in 0..100 {
        let bt = Backtrace::force_capture();
        println!("{}", bt); println!("{:?}", bt);
    }
}

valgrind output:

==863497== Memcheck, a memory error detector
==863497== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==863497== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==863497== Command: ./target/debug/repro_memleak
==863497== Parent PID: 575326
==863497== 
==863497== 
==863497== HEAP SUMMARY:
==863497==     in use at exit: 687,121 bytes in 243 blocks
==863497==   total heap usage: 2,447 allocs, 2,204 frees, 1,530,442 bytes allocated
==863497== 
==863497== 2,729 bytes in 2 blocks are definitely lost in loss record 13 of 23
==863497==    at 0x4C29DAF: malloc (vg_replace_malloc.c:309)
==863497==    by 0x1228E2: __rdos_backtrace_alloc (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x1206DE: elf_add (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11FDF6: elf_add (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x120B3B: phdr_callback (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x57B642B: dl_iterate_phdr (in /usr/lib64/libc-2.17.so)
==863497==    by 0x11E93A: __rdos_backtrace_initialize (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E66E: fileline_initialize (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E6E2: __rdos_backtrace_syminfo (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E2AB: backtrace::symbolize::libbacktrace::resolve (libbacktrace.rs:469)
==863497==    by 0x114C91: resolve_frame_unsynchronized<closure-0> (mod.rs:178)
==863497==    by 0x114C91: resolve (backtrace.rs:397)
==863497==    by 0x114C91: <std::backtrace::Backtrace as core::fmt::Display>::fmt (backtrace.rs:339)
==863497==    by 0x131ABB: core::fmt::write (mod.rs:1053)
==863497== 
==863497== 123,804 bytes in 8 blocks are possibly lost in loss record 20 of 23
==863497==    at 0x4C29DAF: malloc (vg_replace_malloc.c:309)
==863497==    by 0x1228E2: __rdos_backtrace_alloc (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x12A6B5: __rdos_backtrace_get_view (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11F3DE: elf_add (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x120B3B: phdr_callback (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x57B642B: dl_iterate_phdr (in /usr/lib64/libc-2.17.so)
==863497==    by 0x11E93A: __rdos_backtrace_initialize (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E66E: fileline_initialize (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E6E2: __rdos_backtrace_syminfo (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E2AB: backtrace::symbolize::libbacktrace::resolve (libbacktrace.rs:469)
==863497==    by 0x114C91: resolve_frame_unsynchronized<closure-0> (mod.rs:178)
==863497==    by 0x114C91: resolve (backtrace.rs:397)
==863497==    by 0x114C91: <std::backtrace::Backtrace as core::fmt::Display>::fmt (backtrace.rs:339)
==863497==    by 0x131ABB: core::fmt::write (mod.rs:1053)
==863497== 
==863497== 126,992 bytes in 1 blocks are possibly lost in loss record 21 of 23
==863497==    at 0x4C29DAF: malloc (vg_replace_malloc.c:309)
==863497==    by 0x1228E2: __rdos_backtrace_alloc (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x12A6B5: __rdos_backtrace_get_view (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11F3DE: elf_add (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E8DC: __rdos_backtrace_initialize (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E66E: fileline_initialize (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E6E2: __rdos_backtrace_syminfo (in /home/davidwg/work/repro_memleak/target/debug/repro_memleak)
==863497==    by 0x11E2AB: backtrace::symbolize::libbacktrace::resolve (libbacktrace.rs:469)
==863497==    by 0x114C91: resolve_frame_unsynchronized<closure-0> (mod.rs:178)
==863497==    by 0x114C91: resolve (backtrace.rs:397)
==863497==    by 0x114C91: <std::backtrace::Backtrace as core::fmt::Display>::fmt (backtrace.rs:339)
==863497==    by 0x131ABB: core::fmt::write (mod.rs:1053)
==863497==    by 0x11685F: write_fmt<std::io::stdio::StdoutLock> (mod.rs:1428)
==863497==    by 0x11685F: <std::io::stdio::Stdout as std::io::Write>::write_fmt (stdio.rs:549)
==863497==    by 0x116F3D: {{closure}}<std::io::stdio::Stdout> (stdio.rs:800)
==863497==    by 0x116F3D: try_with<core::cell::RefCell<core::option::Option<alloc::boxed::Box<Write>>>,closure-0,core::result::Result<(), std::io::error::Error>> (local.rs:262)
==863497==    by 0x116F3D: print_to<std::io::stdio::Stdout> (stdio.rs:793)
==863497==    by 0x116F3D: std::io::stdio::_print (stdio.rs:817)
==863497== 
==863497== LEAK SUMMARY:
==863497==    definitely lost: 2,729 bytes in 2 blocks
==863497==    indirectly lost: 0 bytes in 0 blocks
==863497==      possibly lost: 250,796 bytes in 9 blocks
==863497==    still reachable: 433,596 bytes in 232 blocks
==863497==         suppressed: 0 bytes in 0 blocks
==863497== Reachable blocks (those to which a pointer was found) are not shown.
==863497== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==863497== 
==863497== For lists of detected and suppressed errors, rerun with: -s
==863497== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
@jonas-schievink jonas-schievink added A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Mar 4, 2020
@tmiasko
Copy link
Contributor

tmiasko commented Mar 5, 2020

Thanks for the report. I think it will be addressed in the next upgrade of
libbacktrace. You can track the progress in rust-lang/libbacktrace#1,
or rust-lang/backtrace-rs#299.

Duplicate of #59125.

@jonas-schievink
Copy link
Contributor

Closing as a duplicate then

sausagee added a commit to sausagee/libra that referenced this issue Mar 11, 2020
Suppress leak until next libbacktrace is released. See details in

rust-lang/rust#69721 (comment)
bors-libra pushed a commit to diem/diem that referenced this issue Mar 11, 2020
Suppress leak until next libbacktrace is released. See details in

rust-lang/rust#69721 (comment)

Closes: #2891
Approved by: mimoo
DavidLDill pushed a commit to DavidLDill/libra that referenced this issue Mar 13, 2020
Suppress leak until next libbacktrace is released. See details in

rust-lang/rust#69721 (comment)

Closes: diem#2891
Approved by: mimoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants