]> Repositorios git - scryer-prolog.git/commitdiff
fix copy_term/3 infinite looping on cyclic terms
authorMark Thom <[email protected]>
Wed, 4 Dec 2019 05:01:38 +0000 (22:01 -0700)
committerMark Thom <[email protected]>
Wed, 4 Dec 2019 05:01:38 +0000 (22:01 -0700)
src/prolog/machine/copier.rs

index 51a56dd20670634a7870180b623bfb1d98d3cf14..13e21ee360c3c734501205b560d526f60aca9fb2 100644 (file)
@@ -90,6 +90,11 @@ impl<T: CopierTarget> CopyTermState<T> {
             ra @ Addr::AttrVar(_) | ra @ Addr::HeapCell(..) | ra @ Addr::StackCell(..) => {
                 if ra == rd {
                     self.reinstantiate_var(ra, threshold);
+
+                    if let AttrVarPolicy::StripAttributes = self.attr_var_policy {
+                        self.trail.push((Ref::HeapCell(addr), self.target[addr].clone()));
+                        self.target[addr] = HeapCellValue::Addr(Addr::HeapCell(threshold));
+                    }
                 } else {
                     self.target[threshold] = HeapCellValue::Addr(ra);
                 }