Merge pull request #2756 from adri326/fix-load-context-unreachable

Fix load_context_module triggering unreachable!()
This commit is contained in:
Mark Thom
2025-01-11 21:27:32 -07:00
committed by GitHub
3 changed files with 11 additions and 2 deletions

View File

@@ -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 => {

View File

@@ -0,0 +1 @@
:- initialization((M = user, loader:load_context(M))).

View File

@@ -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", "");
}