Skip to content

Commit

Permalink
Fix heap error with cloning terms
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Oct 18, 2023
1 parent 7c424b7 commit 2deba0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ static cell *deep_clone2_to_tmp(query *q, cell *p1, pl_idx p1_ctx, unsigned dept

both = 0;
if (deep_copy(t)) DEREF_SLOT(both, e->vgen2, e, e->vgen, t, t_ctx, q->vgen);
if (both) q->cycle_error = true;
p1 = t;
p1_ctx = t_ctx;

Expand All @@ -239,11 +240,10 @@ static cell *deep_clone2_to_tmp(query *q, cell *p1, pl_idx p1_ctx, unsigned dept
cell *rec = deep_clone2_to_tmp(q, p1, p1_ctx, depth+1);
if (!rec) return NULL;

#if 0
p1 = save_p1;
p1_ctx = save_p1_ctx;

while (is_iso_list(p1)) {
while (is_iso_list(p1) && !q->cycle_error) {
p1 = p1 + 1; p1 += p1->nbr_cells;
cell *c = p1;
pl_idx c_ctx = p1_ctx;
Expand All @@ -256,7 +256,6 @@ static cell *deep_clone2_to_tmp(query *q, cell *p1, pl_idx p1_ctx, unsigned dept
p1_ctx = q->latest_ctx;
}
}
#endif

tmp = get_tmp_heap(q, save_idx);
tmp->nbr_cells = tmp_heap_used(q) - save_idx;
Expand Down
2 changes: 1 addition & 1 deletion src/unify.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ static bool unify_lists(query *q, cell *p1, pl_idx p1_ctx, cell *p2, pl_idx p2_c
p2_ctx = orig_p2_ctx;
unsigned cnt = 0;

while (is_iso_list(p1) && is_iso_list(p2)) {
while (is_iso_list(p1) && is_iso_list(p2) && !q->cycle_error) {
p1 = p1 + 1; p1 += p1->nbr_cells;
p2 = p2 + 1; p2 += p2->nbr_cells;

Expand Down

0 comments on commit 2deba0c

Please sign in to comment.