From ea303b4d8b4b5acf4b9cb57c99e718f97b5a223b Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sat, 22 Oct 2022 20:44:50 +0200 Subject: [PATCH] Save instruction pointer for async messages This ensures that if we panic due to sending a message to the current process, we print the correct stacktrace; instead of trying to get the location of the instruction _after_ the send. This fixes https://gitlab.com/inko-lang/inko/-/issues/294. Changelog: fixed --- vm/src/machine.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vm/src/machine.rs b/vm/src/machine.rs index 14e487d08..d77ca1903 100644 --- a/vm/src/machine.rs +++ b/vm/src/machine.rs @@ -570,6 +570,11 @@ impl<'a> Machine<'a> { let reg = ins.arg(0); let rec = state.context.get_register(ins.arg(1)); let method = ins.arg(2); + + // We save in case of a panic, otherwise we may be missing + // stack frames in the resulting stack trace. + state.save(); + let res = process::send_async_message( self.state, thread, process, task, rec, method, )?;