|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 3/3] libxl: ocaml: use 'for_app_registration' in osevent callbacks
Rob Hoes writes ("Re: [PATCH 3/3] libxl: ocaml: use 'for_app_registration' in
osevent callbacks"):
> I forgot to reply to this:
>
> On 12 Dec 2013, at 17:40, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote:
> >> [...]
> >> + for_app = malloc(sizeof(value));
> >> + if (for_app) {
> >> + *for_app = caml_callbackN(*func, 4, args);
> >
> > Can the callbackN fail, eg. returning an exception or something?
>
> Yes, it can:
>
> "If the function f does not return, but raises an exception that escapes the
> scope of the application, then this exception is propagated to the next
> enclosing OCaml code, skipping over the C code. That is, if an OCaml function
> f calls a C function g that calls back an OCaml function h that raises a
> stray exception, then the execution of g is interrupted and the exception is
> propagated back into f.”
> [http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual033.html#toc148]
How alarming. I think this will therefore skip over all the function
epilogue and leave various stuff (including stuff on the now-unwould
stack frame) wired into the ocaml gc.
And of course it will unwind past libxl, leaving the libxl ctx lock
held.
> It is possible to catch the exception in C, e.g.:
>
> res = caml_callbackN_exn(*func, 4, args);
> if(Is_exception_result(res)) {
> res = Extract_exception(res);
> ...
>
> Perhaps it makes sense to do this, and return ERROR_OSEVENT_REG_FAIL when we
> catch an exception.
Yes, absolutely, you must do that. Although the results are still not
going to be good. In the worst case libxl will signal a disaster.
I didn't write in lixbl_event.h that the callbacks weren't allowed to
longjmp rather than returning because I thought it was obvious.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |