summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-06-29 19:38:35 +0200
committerJo-Philipp Wich <jo@mein.io>2022-06-29 19:40:19 +0200
commitf673096f93223e166041f5064389e864c805d804 (patch)
treeef40dccb7a3d9ecb704db6d3026c4e5bd96ee150
parentca72892f2a85ae17a31473c5a08ebbf8138b27dc (diff)
uloop: end uloop on exceptions in managed code
Instead of silently continuing, end the uloop when encountering exceptions in ucode callbacks to let those exceptions propagate to the host program. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--lib/uloop.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/uloop.c b/lib/uloop.c
index 6acb347..ef77001 100644
--- a/lib/uloop.c
+++ b/lib/uloop.c
@@ -884,11 +884,13 @@ uc_uloop_task_output_cb(struct uloop_fd *fd, unsigned int flags)
uc_vm_stack_push(task->vm, ucv_get(obj));
uc_vm_stack_push(task->vm, ucv_get(task->input_cb));
- if (uc_vm_call(task->vm, true, 0) == EXCEPTION_NONE)
- msg = uc_vm_stack_pop(task->vm);
- else
- msg = NULL;
+ if (uc_vm_call(task->vm, true, 0) != EXCEPTION_NONE) {
+ uloop_end();
+ return;
+ }
+
+ msg = uc_vm_stack_pop(task->vm);
uc_uloop_pipe_send_common(task->vm, msg, task->input_fd);
ucv_put(msg);
@@ -903,8 +905,14 @@ uc_uloop_task_output_cb(struct uloop_fd *fd, unsigned int flags)
uc_vm_stack_push(task->vm, ucv_get(task->output_cb));
uc_vm_stack_push(task->vm, msg);
- if (uc_vm_call(task->vm, true, 1) == EXCEPTION_NONE)
+ if (uc_vm_call(task->vm, true, 1) == EXCEPTION_NONE) {
ucv_put(uc_vm_stack_pop(task->vm));
+ }
+ else {
+ uloop_end();
+
+ return;
+ }
}
}