|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 11/28] libxl: ocaml: propagate the libxl return error code in exceptions
On Tue, 2013-03-26 at 11:33 +0000, Dave Scott wrote:
> On 25/03/13 14:45, Rob Hoes wrote:
> > +static void failwith_xl(int error, char *fname)
> > +{
> > + CAMLlocal1(arg);
> > value *exc = caml_named_value("Xenlight.Error");
> > +
> > if (!exc)
> > caml_invalid_argument("Exception Xenlight.Error not
> > initialized, please link xl.cma");
> > - caml_raise_with_string(*exc, fname);
> > +
> > + arg = caml_alloc_small(2, 0);
> > +
> > + Field(arg, 0) = Val_error(error);
> > + Field(arg, 1) = caml_copy_string(fname);
>
> I think this violates Rule 5 in the OCaml FFI manual[*]. In the
> low-level interface when you allocate a block with "caml_alloc_small"
> all the fields contain random values. The assignment:
>
> Field(arg, 1) = caml_copy_string(fname);
>
> will first call "caml_copy_string" which performs an allocation before
> setting the field to a valid value. Any function which performs an
> allocation can trigger a GC which will segfault if it sees the random
> data in field 1.
I think this answers my earlier query on another patch about the
redundant looking store to Field ...
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |