From 15652544786b6787af29cae9bc0bb16d49d48fb4 Mon Sep 17 00:00:00 2001 From: uellenberg Date: Mon, 27 Jan 2025 16:21:08 -0800 Subject: Fix off-by-one error causing driftsort to crash Fixes #136103. Based on the analysis by @jonathan-gruber-jg and @orlp. --- tests/ui/array-slice-vec/driftsort-off-by-one-issue-136103.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/ui/array-slice-vec/driftsort-off-by-one-issue-136103.rs (limited to 'tests/ui/array-slice-vec') diff --git a/tests/ui/array-slice-vec/driftsort-off-by-one-issue-136103.rs b/tests/ui/array-slice-vec/driftsort-off-by-one-issue-136103.rs new file mode 100644 index 00000000000..42197ff102d --- /dev/null +++ b/tests/ui/array-slice-vec/driftsort-off-by-one-issue-136103.rs @@ -0,0 +1,10 @@ +//@ run-pass +// Ensures that driftsort doesn't crash under specific slice +// length and memory size. +// Based on the example given in https://github.com/rust-lang/rust/issues/136103. +fn main() { + let n = 127; + let mut objs: Vec<_> = + (0..n).map(|i| [(i % 2) as u8; 125001]).collect(); + objs.sort(); +} -- cgit 1.4.1-3-g733a5