diff --git a/src/codegen/compile.ml b/src/codegen/compile.ml index b6aace36dca..7a7dace7661 100644 --- a/src/codegen/compile.ml +++ b/src/codegen/compile.ml @@ -6361,9 +6361,11 @@ module FuncDec = struct get_cb_index let ignoring_callback env = - let name = "@ignore_callback" in - Func.define_built_in env name ["env", I32Type] [] (fun env -> G.nop); - compile_unboxed_const (E.add_fun_ptr env (E.built_in env name)) + (* for one-way calls, we use an invalid table entry as the callback. this + way, the callback, when it comes back, will (safely) trap, even if the + module has completely changed in between. This way, one-way calls do not + get in the way of safe instantaneous upgrades *) + compile_unboxed_const (-1l) let cleanup_callback env = let name = "@cleanup_callback" in diff --git a/test/run-drun/ok/oneshot-callbacks.ic-ref-run.ok b/test/run-drun/ok/oneshot-callbacks.ic-ref-run.ok index facceb4fe9b..e78b94dda59 100644 --- a/test/run-drun/ok/oneshot-callbacks.ic-ref-run.ok +++ b/test/run-drun/ok/oneshot-callbacks.ic-ref-run.ok @@ -53,7 +53,7 @@ debug.print: ping! 1 debug.print: go 1: 1 debug.print: ping-async! 1 debug.print: go 2: 1 -← rejected (RC_CANISTER_ERROR): canister did not respond +← rejected (RC_CANISTER_ERROR): canister trapped: EvalTrapError :0.1 "uninitialized element -1" → update go(false) debug.print: go 0: 0 debug.print: ping! 1 @@ -67,4 +67,4 @@ debug.print: ping! 1 debug.print: go 1: 1 debug.print: ping-async! 1 debug.print: go 2: 1 -← rejected (RC_CANISTER_ERROR): canister did not respond +← rejected (RC_CANISTER_ERROR): canister trapped: EvalTrapError :0.1 "uninitialized element -1"