From 6308ce454413d226243a6c7fc79377c9e28c3b42 Mon Sep 17 00:00:00 2001 From: alpaylan Date: Sat, 8 Feb 2025 09:34:51 -0500 Subject: [PATCH 1/5] fix the shrinking file and poison errors --- simulator/main.rs | 10 +++++----- simulator/runner/execution.rs | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/simulator/main.rs b/simulator/main.rs index 82c39b809..b40934cfc 100644 --- a/simulator/main.rs +++ b/simulator/main.rs @@ -233,6 +233,11 @@ fn run_simulator( }) .collect::>(); + + // Write the shrunk plan to a file + let mut f = std::fs::File::create(&paths.shrunk_plan).unwrap(); + f.write_all(shrunk_plans[0].to_string().as_bytes()).unwrap(); + let last_execution = Arc::new(Mutex::new(*last_execution)); let shrunk = SandboxedResult::from( @@ -270,11 +275,6 @@ fn run_simulator( log::error!("shrinking failed, the error was not properly reproduced"); } } - - // Write the shrunk plan to a file - let shrunk_plan = std::fs::read(&paths.shrunk_plan).unwrap(); - let mut f = std::fs::File::create(&paths.shrunk_plan).unwrap(); - f.write_all(&shrunk_plan).unwrap(); } } } diff --git a/simulator/runner/execution.rs b/simulator/runner/execution.rs index 6544928a1..6342dff3a 100644 --- a/simulator/runner/execution.rs +++ b/simulator/runner/execution.rs @@ -62,6 +62,7 @@ pub(crate) fn execute_plans( ) -> ExecutionResult { let mut history = ExecutionHistory::new(); let now = std::time::Instant::now(); + env.clear_poison(); let mut env = env.lock().unwrap(); for _tick in 0..env.opts.ticks { // Pick the connection to interact with From 4362bc16a3876aed31e21056d31529e1fb7f6d8c Mon Sep 17 00:00:00 2001 From: alpaylan Date: Sat, 8 Feb 2025 09:37:08 -0500 Subject: [PATCH 2/5] fix formatting --- simulator/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/simulator/main.rs b/simulator/main.rs index b40934cfc..2eb463529 100644 --- a/simulator/main.rs +++ b/simulator/main.rs @@ -233,7 +233,6 @@ fn run_simulator( }) .collect::>(); - // Write the shrunk plan to a file let mut f = std::fs::File::create(&paths.shrunk_plan).unwrap(); f.write_all(shrunk_plans[0].to_string().as_bytes()).unwrap(); From 3ae3e650aed41823767fdbd1f3924f2fcc3063f4 Mon Sep 17 00:00:00 2001 From: alpaylan Date: Sat, 8 Feb 2025 10:59:11 -0500 Subject: [PATCH 3/5] fix watch mode bug deleting the last interaction of a property --- simulator/generation/plan.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/simulator/generation/plan.rs b/simulator/generation/plan.rs index d06cdfff3..b601a8975 100644 --- a/simulator/generation/plan.rs +++ b/simulator/generation/plan.rs @@ -57,8 +57,11 @@ impl InteractionPlan { i += 1; continue; } - - if interactions[i].contains(plan[j1][j2].to_string().as_str()) { + if plan[j1].len() == j2 { + i += 1; + j1 += 1; + j2 = 0; + } else if interactions[i].contains(plan[j1][j2].to_string().as_str()) { i += 1; if j2 + 1 < plan[j1].len() { j2 += 1; From 69d72da837d0668e93f671a6692f63546c97c064 Mon Sep 17 00:00:00 2001 From: alpaylan Date: Sat, 8 Feb 2025 12:53:25 -0500 Subject: [PATCH 4/5] fix the diff computing algorithm --- simulator/generation/plan.rs | 48 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/simulator/generation/plan.rs b/simulator/generation/plan.rs index b601a8975..ce24e0693 100644 --- a/simulator/generation/plan.rs +++ b/simulator/generation/plan.rs @@ -47,9 +47,9 @@ impl InteractionPlan { .map(|i| i.interactions()) .collect::>(); - let (mut i, mut j1, mut j2) = (0, 0, 0); + let (mut i, mut j) = (0, 0); - while i < interactions.len() && j1 < plan.len() { + while i < interactions.len() && j < plan.len() { if interactions[i].starts_with("-- begin") || interactions[i].starts_with("-- end") || interactions[i].is_empty() @@ -57,32 +57,32 @@ impl InteractionPlan { i += 1; continue; } - if plan[j1].len() == j2 { - i += 1; - j1 += 1; - j2 = 0; - } else if interactions[i].contains(plan[j1][j2].to_string().as_str()) { - i += 1; - if j2 + 1 < plan[j1].len() { - j2 += 1; - } else { - j1 += 1; - j2 = 0; - } - } else { - plan[j1].remove(j2); - if plan[j1].is_empty() { - plan.remove(j1); - j2 = 0; + // interactions[i] is the i'th line in the human readable plan + // plan[j][k] is the k'th interaction in the j'th property + let mut k = 0; + + while k < plan[j].len() { + + if i >= interactions.len() { + let _ = plan.split_off(j + 1); + let _ = plan[j].split_off(k); + break; + } + + if interactions[i].contains(plan[j][k].to_string().as_str()) { + i += 1; + k += 1; + } else { + plan[j].remove(k); } } - } - if j1 < plan.len() { - if j2 < plan[j1].len() { - let _ = plan[j1].split_off(j2); + + if plan[j].is_empty() { + plan.remove(j); + } else { + j += 1; } - let _ = plan.split_off(j1); } plan From 7ddbcf07afe49821b1235be2f40e1a294d62fd54 Mon Sep 17 00:00:00 2001 From: alpaylan Date: Sat, 8 Feb 2025 15:41:57 -0500 Subject: [PATCH 5/5] fix formatting --- simulator/generation/plan.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/simulator/generation/plan.rs b/simulator/generation/plan.rs index ce24e0693..cf41c1060 100644 --- a/simulator/generation/plan.rs +++ b/simulator/generation/plan.rs @@ -63,7 +63,6 @@ impl InteractionPlan { let mut k = 0; while k < plan[j].len() { - if i >= interactions.len() { let _ = plan.split_off(j + 1); let _ = plan[j].split_off(k);