Skip to content

Commit 54322a5

Browse files
committed
fix: handle RevisitPlacement in symbolic revisit checks
1 parent 4bbf310 commit 54322a5

2 files changed

Lines changed: 28 additions & 21 deletions

File tree

traceforge/src/exec_graph.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,30 @@ impl ExecutionGraph {
839839
}
840840
}
841841

842+
/// Change the rf of `pos` according to a revisit placement, dispatching to
843+
/// `change_rf` for a single send or `change_inbox_rfs` for a whole inbox
844+
/// send set. Used both for in-place revisits and for the symbolic what-if
845+
/// checks that operate on a copied graph.
846+
pub(crate) fn change_rf_placement(&mut self, pos: Event, placement: &RevisitPlacement) {
847+
match placement {
848+
RevisitPlacement::Default(send) => {
849+
// Standard recv revisit: single rf edge.
850+
self.change_rf(pos, Some(*send));
851+
}
852+
RevisitPlacement::Inbox(sends) => {
853+
// Inbox revisit: whole set of chosen sends.
854+
if sends.is_empty() {
855+
self.change_inbox_rfs(pos, None);
856+
} else {
857+
let mut sorted = sends.clone();
858+
// Keep a canonical order for deterministic comparisons/printing.
859+
sorted.sort();
860+
self.change_inbox_rfs(pos, Some(sorted));
861+
}
862+
}
863+
}
864+
}
865+
842866
fn check_spawn_invariants(&self) {
843867
// This function checks the consistency of the information about which thread spawned
844868
// which, and at what event number.

traceforge/src/must.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,7 @@ impl Must {
10431043
solver
10441044
}
10451045

1046+
// TODO: This code is never run. Change it in the future.
10461047
#[cfg(feature = "symbolic")]
10471048
fn symbolic_backward_revisit_is_sat(&self, rev: &Revisit) -> bool {
10481049
if !self.config.symbolic {
@@ -1051,7 +1052,7 @@ impl Must {
10511052

10521053
let view = self.current.graph.revisit_view(rev);
10531054
let mut g = self.current.graph.copy_to_view(&view);
1054-
g.change_rf(rev.pos, Some(rev.rev));
1055+
g.change_rf_placement(rev.pos, &rev.rev);
10551056

10561057
self.symbolic_solver_for_graph(&g).is_sat()
10571058
}
@@ -1060,7 +1061,7 @@ impl Must {
10601061
fn is_maximal_constraint(&self, c: &ConstraintEval, rev: &Revisit) -> bool {
10611062
let view = self.current.graph.revisit_view(rev);
10621063
let mut g = self.current.graph.copy_to_view(&view);
1063-
g.change_rf(rev.pos, Some(rev.rev));
1064+
g.change_rf_placement(rev.pos, &rev.rev);
10641065

10651066
let solver = self.symbolic_solver_for_graph(&g);
10661067

@@ -2157,25 +2158,7 @@ impl Must {
21572158

21582159
/// Change an rf according to the revisit
21592160
fn change_rf(&mut self, rev: &Revisit) {
2160-
match &rev.rev {
2161-
RevisitPlacement::Default(vv) => {
2162-
// Standard recv revisit: single rf edge.
2163-
self.current.graph.change_rf(rev.pos, Some(*vv));
2164-
}
2165-
RevisitPlacement::Inbox(vv) => {
2166-
// Inbox revisit: whole set of chosen sends.
2167-
if vv.is_empty() {
2168-
self.current.graph.change_inbox_rfs(rev.pos, None);
2169-
} else {
2170-
let mut vv_sorted = vv.clone();
2171-
// Keep a canonical order for deterministic comparisons/printing.
2172-
vv_sorted.sort();
2173-
self.current
2174-
.graph
2175-
.change_inbox_rfs(rev.pos, Some(vv_sorted));
2176-
}
2177-
}
2178-
}
2161+
self.current.graph.change_rf_placement(rev.pos, &rev.rev);
21792162
}
21802163

21812164
fn pick_revisit(&mut self, revs: Vec<Event>, pos: Event) {

0 commit comments

Comments
 (0)