Skip to content

Commit

Permalink
Merge pull request #2756 from adri326/fix-load-context-unreachable
Browse files Browse the repository at this point in the history
Fix load_context_module triggering unreachable!()
  • Loading branch information
mthom authored Jan 12, 2025
2 parents 2856cc4 + eff094c commit 1ed4fe6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/machine/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4812,11 +4812,11 @@ impl Machine {
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
}
&Instruction::CallLoadContextModule => {
self.load_context_module(self.machine_st.registers[1]);
self.load_context_module(self.deref_register(1));
step_or_fail!(self, self.machine_st.p += 1);
}
&Instruction::ExecuteLoadContextModule => {
self.load_context_module(self.machine_st.registers[1]);
self.load_context_module(self.deref_register(1));
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
}
&Instruction::CallLoadContextStream => {
Expand Down
1 change: 1 addition & 0 deletions tests-pl/load-context-unreachable.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:- initialization((M = user, loader:load_context(M))).
8 changes: 8 additions & 0 deletions tests/scryer/issues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ fn issue2588_load_html() {
fn call_qualification() {
load_module_test("tests-pl/issue2361-call-qualified.pl", "");
}

// PR #2756: ensures that calling load_context with a bound variable doesn't trigger unreachable!()
#[serial]
#[test]
#[cfg_attr(miri, ignore = "it takes too long to run")]
fn load_context_unreachable() {
load_module_test("tests-pl/load-context-unreachable.pl", "");
}

0 comments on commit 1ed4fe6

Please sign in to comment.