You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::str::Chars;pubstructThisIsNotEvenUsed<'a>{never_used:Chars<'a>,}impl<'a>IteratorforThisIsNotEvenUsed<'a>{typeItem = ();fnnext(&mutself) -> Option<Self::Item>{todo!()}fncount(self) -> usize{// mere existence of this line causes crash!self.never_used.count()}}
crashy/tests/crash.rs
use crashy;// unused, but important#[test]fncrash(){// doesn't crash if the char is ASCIIlet _s = ['\u{80}'].iter().collect::<String>();}
Compile with:
CARGO_INCREMENTAL=0RUSTFLAGS='-Zprofile -Cinline-threshold=0 -Clink-dead-code' cargo test
#0 __memmove_avx_unaligned_erms ()
at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:287
#1 0x000055555557853e in alloc::vec::Vec<T,A>::append_elements (
self=0x7ffff7c19660, other=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/vec/mod.rs:1607
#2 <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<&T,core::slice::iter::Iter<T>>>::spec_extend (self=0x7ffff7c19660, iterator=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/vec/spec_extend.rs:80
#3 0x000055555557d29c in alloc::vec::Vec<T,A>::extend_from_slice (
self=0x7ffff7c19660, other=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/vec/mod.rs:2016
#4 0x000055555557e663 in alloc::string::String::push (self=0x7ffff7c19660,
ch=128 '\200')
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/string.rs:1082
#5 0x000055555557ac06 in <alloc::string::String as core::iter::traits::collect::Extend<char>>::extend::{{closure}} (c=128 '\200')
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/string.rs:1778
#6 core::iter::traits::iterator::Iterator::for_each::call::{{closure}} (
item=128 '\200')
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/iter/traits/iterator.rs:772
#7 core::iter::adapters::map::map_fold::{{closure}} (
elt=0x555555692120 "\200the test returned a termination value with a non-zero status code () which indicates a failure/rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/test/src/lib.rs\000\000\000", acc=<optimized out>)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/iter/adapters/map.rs:81
#8 core::iter::traits::iterator::Iterator::fold (self=..., init=(), f=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/iter/traits/iterator.rs:2123
#9 0x0000555555577e75 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold (self=..., init=(), g=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/iter/ad--Type <RET> for more, q to quit, c to continue without paging--
apters/map.rs:121
#10 0x0000555555577f7f in <core::iter::adapters::cloned::Cloned<I> as core::iter::traits::iterator::Iterator>::fold (self=..., init=(), f=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/iter/adapters/cloned.rs:58
#11 0x0000555555580566 in core::iter::traits::iterator::Iterator::for_each (
self=..., f=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/iter/traits/iterator.rs:775
#12 <alloc::string::String as core::iter::traits::collect::Extend<char>>::extend (self=0x7ffff7c19660, iter=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/string.rs:1778
#13 0x000055555558097b in <alloc::string::String as core::iter::traits::collect::Extend<&char>>::extend (self=0x7ffff7c19660, iter=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/string.rs:1795
#14 0x0000555555580a42 in <alloc::string::String as core::iter::traits::collect::FromIterator<&char>>::from_iter (iter=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/string.rs:1712
#15 0x0000555555580c19 in core::iter::traits::iterator::Iterator::collect (
self=...)
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/iter/traits/iterator.rs:1764
#16 crash::crash () at tests/crash.rs:6
#17 0x00005555555794d1 in crash::crash::{{closure}} () at tests/crash.rs:4
#18 core::ops::function::FnOnce::call_once ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/ops/function.rs:227
#19 0x00005555555ae096 in core::ops::function::FnOnce::call_once ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/ops/function.rs:227
#20 test::__rust_begin_short_backtrace () at library/test/src/lib.rs:567
#21 0x00005555555ac78e in <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/boxed.rs:1546
--Type <RET> for more, q to quit, c to continue without paging--
#22 <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/panic.rs:344
#23 std::panicking::try::do_call ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/panicking.rs:379
#24 std::panicking::try ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/panicking.rs:343
#25 std::panic::catch_unwind ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/panic.rs:431
#26 test::run_test_in_process () at library/test/src/lib.rs:589
#27 test::run_test::run_test_inner::{{closure}} ()
at library/test/src/lib.rs:486
#28 0x000055555558212a in test::run_test::run_test_inner::{{closure}} ()
at library/test/src/lib.rs:511
#29 std::sys_common::backtrace::__rust_begin_short_backtrace ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/sys_common/backtrace.rs:125
#30 0x000055555558748f in std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}} ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/thread/mod.rs:474
#31 <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/panic.rs:344
#32 std::panicking::try::do_call ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/panicking.rs:379
#33 std::panicking::try ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/panicking.rs:343
#34 std::panic::catch_unwind ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/panic.rs:431
--Type <RET> for more, q to quit, c to continue without paging--
#35 std::thread::Builder::spawn_unchecked::{{closure}} ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/std/src/thread/mod.rs:473
#36 core::ops::function::FnOnce::call_once{{vtable-shim}} ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/core/src/ops/function.rs:227
#37 0x0000555555619f88 in <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once ()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/boxed.rs:1546
#38 <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
()
at /rustc/f98721f886ab52d32d622ad0a46216ad03f3e525/library/alloc/src/boxed.rs:1546
#39 std::sys::unix::thread::Thread::new::thread_start ()
at library/std/src/sys/unix/thread.rs:71
#40 0x00007ffff7f70fa3 in start_thread (arg=<optimized out>)
at pthread_create.c:486
#41 0x00007ffff7d194cf in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
The text was updated successfully, but these errors were encountered:
FYI: The -C inline-threshold=0, enables inlining with threshold 0, which makes inlining more likely than the default behaviour for -C opt-level=0, which is to only inline functions with #[inline(always)] attribute.
Source: kornelski/deunicode#5 (comment)
I tried this code:
crashy/lib.rs
crashy/tests/crash.rs
Compile with:
I expected to see this happen: The test passes.
Instead, this happened: The test SIGSEGVs.
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: