Skip to content

Commit

Permalink
uloop: end uloop on exceptions in managed code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jow- committed Jun 29, 2022
1 parent ca72892 commit f673096
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/uloop.c
Expand Up @@ -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);

Expand All @@ -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;
}
}
}

Expand Down

0 comments on commit f673096

Please sign in to comment.