fix empty iterator crash, restart

This commit is contained in:
Alwin Berger 2023-05-02 09:41:53 +02:00
parent 6a042da5c1
commit a328ddfd5f
2 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import csv import csv
def_flags="--no-default-features --features std,snapshot_restore,singlecore" def_flags="--no-default-features --features std,snapshot_restore,singlecore,restarting"
remote="mnt/" remote="mnt/"
rule build_showmap: rule build_showmap:

View File

@ -305,11 +305,13 @@ where
let untouched : Vec<_> = marks.iter().filter( let untouched : Vec<_> = marks.iter().filter(
|x| x.2 == 0 |x| x.2 == 0
).collect(); ).collect();
if untouched.len() > 0 {
let tmp = interrupt_offsets[i]; let tmp = interrupt_offsets[i];
let choice = myrand.choose(untouched); let choice = myrand.choose(untouched);
interrupt_offsets[i] = myrand.between(choice.0.start_tick, choice.0.end_tick) interrupt_offsets[i] = myrand.between(choice.0.start_tick, choice.0.end_tick)
.try_into().expect("tick > u32"); .try_into().expect("tick > u32");
do_rerun = true; do_rerun = true;
}
// println!("no alternatives, choose random i: {} {} -> {}",i,tmp,interrupt_offsets[i]); // println!("no alternatives, choose random i: {} {} -> {}",i,tmp,interrupt_offsets[i]);
continue; continue;
} else { } else {