Closed
Description
The following code:
fn main() {
let _string = "foobar".to_string();
}
causes the following error when compiled with RUSTFLAG="-Z sanitizer=memory"
:
==8391==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x55fba33e0fb4 in _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..ops..deref..DerefMut$GT$::deref_mut::h3a0e58767aa3b236 /checkout/src/liballoc/vec.rs:1762:12
#1 0x55fba33e1122 in _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..ops..index..IndexMut$LT$I$GT$$GT$::index_mut::hb2387792320c3e0a /checkout/src/liballoc/vec.rs:1740:33
#2 0x55fba33e0ea8 in _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::hc074c17d1983d45e /checkout/src/liballoc/vec.rs:2186:36
#3 0x55fba33e13cb in core::ptr::drop_in_place::hb4be232c9bbba2a8 /checkout/src/libcore/ptr.rs:59
#4 0x55fba33e14a9 in core::ptr::drop_in_place::hbc9ae6e2a77742fc /checkout/src/libcore/ptr.rs:59
#5 0x55fba33e0b53 in rust_test::main::hbdb4645a96927ff3 /path/to/rust-test/src/main.rs:3
#6 0x55fba33dfc25 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hdbb070f7f9cb20f3 /checkout/src/libstd/rt.rs:74:33
#7 0x55fba3444a72 in std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::hf9ed89fe31802c27 /checkout/src/libstd/rt.rs:59:12
#8 0x55fba3444a72 in _ZN3std9panicking3try7do_call17h34f710c6c7436ab4E.llvm.17120388486034956999 /checkout/src/libstd/panicking.rs:310
#9 0x55fba3452b59 in __rust_maybe_catch_panic /checkout/src/libpanic_unwind/lib.rs:102:7
#10 0x55fba343b2f5 in std::panicking::try::hde1f350b7d320158 /checkout/src/libstd/panicking.rs:289:12
#11 0x55fba343b2f5 in std::panic::catch_unwind::h36d4846b7bd01358 /checkout/src/libstd/panic.rs:392
#12 0x55fba343b2f5 in std::rt::lang_start_internal::hb067be5f5219a9c5 /checkout/src/libstd/rt.rs:58
#13 0x55fba33dfb4e in std::rt::lang_start::h0fc74e8614dd1c16 /checkout/src/libstd/rt.rs:74:4
#14 0x55fba33e0bc1 in main (/path/to/rust-test/target/debug/rust-test+0xabc1)
#15 0x7f12e6327222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)
#16 0x55fba33df40d in _start (/path/to/rust-test/target/debug/rust-test+0x940d)
Other string usages like calling push()
causes a similar error.
Thanks to fix the issue.