Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/codegen/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/run-drun/ok/oneshot-callbacks.ic-ref-run.ok
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"