Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: eijiro_sumii@anet.ne.jp
Cc: caml-list@inria.fr, sumii@venus.is.s.u-tokyo.ac.jp
Subject: Re: [Caml-list] questions about marshalling
Date: Mon, 19 Mar 2001 11:42:10 +0100	[thread overview]
Message-ID: <20010319114210.A30440@pauillac.inria.fr> (raw)
In-Reply-To: <20010317230450C.sumii@yl.is.s.u-tokyo.ac.jp>; from eijiro_sumii@anet.ne.jp on Sat, Mar 17, 2001 at 11:04:50PM +0900

> (1) Is it safe to marshal values of a statically polymorphic type, like
> 
>       let f x = Marshal.to_channel outchan (x, x) [Marshal.Closures]
> 
>     for example, provided that the marshaled values will be unmarshaled as
>     values of the right types at runtime?

Yes, it is safe.

> (2) Is it safe to *un*marshal a value at a statically polymorphic type
>     and use it later at a statically monomorphic type, like
> 
>       let g x = fst x
>       let y : int = g (Marshal.from_channel inchan)
> 
>     for example, provided that the value has the right type at runtime?

Again, provided the run-time type is correct, this is safe.

> My guess is that both of these are safe, even though the document says
> 
>   The programmer should explicitly give the expected type of the
>   returned value, using the following syntax: `(Marshal.from_channel
>   chan : type)'.
> 
> because the (un)marshaling function itself works on the basis of the
> runtime tag rather than the static type of a value -- a catastrophe
> may be caused *later* when the value is actually used at a wrong type.
> Am I correct?

Yes.  The documentation perhaps needs to be worded differently.
Constraining immediately the return value of Marshal.from_channel to
the correct type is a good way to reduce the probability of
programming errors induced by the fake polymorphic type of this
function, but it is not an absolute requirement.

> (3) Yet another question: in a program using marhsaling (via ocamlmpi,
>     actually), I get the following error:
> 
>   Fatal error: uncaught exception Failure("input_value: ill-formed message")
> 
>     What does this mean?  I am quite sure that all the hosts are
>     running the same binary, and I am using only ocamlmpi for
>     communication.  Does this necessarily mean that I gave a wrong
>     type for the unmarshaled value (in Mpi.receive, to be specific),
>     or are there other possibilities?

No, this is not a "wrong type" error.  It means that the binary data
given to the unmarshaler is not valid, e.g. was not produced by the
marshaller, or got corrupted, or truncated, or padded, or whatever
change, during transmission.  This might indicate a bug in ocamlmpi,
or a problem in the underlying MPI implementation or transport layers.

If you have a test program that reproduces the error, you can send it
to me and I'll have a look.

Hope this helps,

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


      reply	other threads:[~2001-03-19 10:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-17 14:04 eijiro_sumii
2001-03-19 10:42 ` Xavier Leroy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010319114210.A30440@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=eijiro_sumii@anet.ne.jp \
    --cc=sumii@venus.is.s.u-tokyo.ac.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox