fix cont function crashes (#2920)

This commit is contained in:
Mark Thom
2025-04-28 23:39:52 -07:00
committed by Mark Thom
parent 4e0493474e
commit d6b6eda77d
3 changed files with 11 additions and 28 deletions

View File

@@ -1261,10 +1261,6 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
let code_len = self.wam_prelude.code.len();
let mut code_ptr = code_len;
if key == (atom!("..."), 2) {
print!("");
}
let mut clauses = vec![];
let mut preprocessor = Preprocessor::new(settings);

View File

@@ -186,26 +186,8 @@ impl IndexMut<RegType> for MachineState {
pub type CallResult = Result<(), Vec<FunctorElement>>;
/*
#[inline(always)]
pub fn pstr_loc_and_offset(heap: &[HeapCellValue], index: usize) -> (usize, Fixnum) {
read_heap_cell!(heap[index],
(HeapCellValueTag::PStr | HeapCellValueTag::CStr) => {
(index, Fixnum::build_with(0))
}
(HeapCellValueTag::PStrOffset, h) => {
(h, cell_as_fixnum!(heap[index+1]))
}
_ => {
unreachable!()
}
)
}
*/
// size may be an upper bound.
// true_size is calculated to compute the exact offset.
fn push_var_eq_functors<'a>(
heap: &mut Heap,
size: usize,

View File

@@ -5711,7 +5711,6 @@ impl Machine {
if addr.get_tag() == HeapCellValueTag::StackVar {
section.push_cell(heap_loc_as_cell!(h + 1 + idx));
self.machine_st.stack[stack_offset] = heap_loc_as_cell!(h + 1 + idx);
// have to inline the TrailRef::Ref(RefTag::StackCell) case of MachineState::trail
@@ -5730,7 +5729,7 @@ impl Machine {
}
});
let chunk = str_loc_as_cell!(self.machine_st.heap.cell_len());
let chunk = str_loc_as_cell!(h);
unify!(self.machine_st, self.machine_st.registers[3], chunk);
}
@@ -6317,13 +6316,13 @@ impl Machine {
let e = and_frame.prelude.e;
let e = Fixnum::build_with(i64::try_from(e).unwrap());
let mut writer = Heap::functor_writer(functor!(atom!("dir_entry"), [fixnum(cp)]));
let p_functor_cell = step_or_resource_error!(machine_st, writer(&mut machine_st.heap));
machine_st.unify_fixnum(e, machine_st.registers[2]);
if !machine_st.fail {
let mut writer = Heap::functor_writer(functor!(atom!("dir_entry"), [fixnum(cp)]));
let p_functor_cell =
step_or_resource_error!(machine_st, writer(&mut machine_st.heap));
unify!(machine_st, p_functor_cell, machine_st.registers[3]);
}
};
@@ -6350,6 +6349,12 @@ impl Machine {
// active permanent variables can be read from
// it later.
let and_frame = self.machine_st.stack.index_and_frame(e);
if and_frame.prelude.cp == 0 {
self.machine_st.fail = true;
return;
}
let cp = and_frame.prelude.cp - 1;
let mut writer = Heap::functor_writer(functor!(atom!("dir_entry"), [fixnum(cp)]));