Skip to content

ubus fixes - #492

Merged
jow- merged 2 commits into
ucode-lang:masterfrom
nbd168:ubus-fix
Oct 13, 2026
Merged

jow- merged 2 commits into
ucode-lang:masterfrom
nbd168:ubus-fix

Conversation

@nbd168

@nbd168 nbd168 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Improve exception handling:

  • handle exceptions in deferred completion callback (similar to other callbacks)
  • properly handle exit() in the guard

uc_ubus_call_user_cb() ran the completion callback of a defer() with a
plain uc_vm_call(), unlike every other user callback, which goes through
uc_ubus_vm_call(). An exception in that callback therefore bypassed the
handler set with guard() and stayed pending in the VM. libubus runs the
completion of a deferred request while any other request on the
connection waits, so the exception then unwound that unrelated caller:
a call() whose reply arrived returned no value and threw the callback's
exception instead.

Run the completion callback through uc_ubus_vm_call() as well.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
uc_ubus_vm_handle_exception() hands every exception of a user callback
to the handler set with guard(), including the one that exit() raises.
The call of the handler clears that exception, so the script keeps
running: the handler receives an exception of type "Exit" and the event
loop continues. Without a guard, the same exit() ends the process with
the requested status.

End the event loop and leave the exit request pending in the VM, the
same as when no guard is set. uc_ubus_handle_reply_common() already
keeps the exit() of a method handler away from the guard.

Fixes: 693af2b ("ubus: add guard() function")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
@jow-
jow- merged commit fa288dd into ucode-lang:master Oct 13, 2026
2 checks passed
@jow-

jow- commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks!

@nbd168
nbd168 deleted the ubus-fix branch October 14, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants