* trouble with Marshal.to_string
@ 2005-10-08 15:34 Norman Ramsey
2005-10-08 16:09 ` [Caml-list] " Anil Madhavapeddy
0 siblings, 1 reply; 6+ messages in thread
From: Norman Ramsey @ 2005-10-08 15:34 UTC (permalink / raw)
To: caml-list
Dear Camllists,
I'm having trouble using Marshal.to_string. My call looks like this:
Marshal.to_string f [Marshal.Closures]
but unfortunately Marshal.to_string raises an exception:
Fatal error: exception Invalid_argument("output_value: abstract value (Custom)")
Unfortunately I can't find any discussion of this possibility in the manual.
Can anybody on the list explain what the problem is and how I might work
around it?
Norman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] trouble with Marshal.to_string
2005-10-08 15:34 trouble with Marshal.to_string Norman Ramsey
@ 2005-10-08 16:09 ` Anil Madhavapeddy
2005-10-08 16:35 ` Norman Ramsey
0 siblings, 1 reply; 6+ messages in thread
From: Anil Madhavapeddy @ 2005-10-08 16:09 UTC (permalink / raw)
To: Norman Ramsey; +Cc: caml-list
On 8 Oct 2005, at 16:34, Norman Ramsey wrote:
> Dear Camllists,
>
> I'm having trouble using Marshal.to_string. My call looks like this:
>
> Marshal.to_string f [Marshal.Closures]
>
> but unfortunately Marshal.to_string raises an exception:
>
> Fatal error: exception Invalid_argument("output_value: abstract
> value (Custom)")
>
Are you using any C bindings which create custom blocks? That error
occurs if your custom block does not define a serialization function
(documented here: http://caml.inria.fr/pub/docs/manual-ocaml/
manual032.html#s:custom).
Anil
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] trouble with Marshal.to_string
2005-10-08 16:09 ` [Caml-list] " Anil Madhavapeddy
@ 2005-10-08 16:35 ` Norman Ramsey
2005-10-08 16:57 ` Anil Madhavapeddy
0 siblings, 1 reply; 6+ messages in thread
From: Norman Ramsey @ 2005-10-08 16:35 UTC (permalink / raw)
To: Anil Madhavapeddy; +Cc: caml-list
> Are you using any C bindings which create custom blocks? That error
> occurs if your custom block does not define a serialization function
> (documented here: http://caml.inria.fr/pub/docs/manual-ocaml/
> manual032.html#s:custom).
Thanks; at least now I have some idea what's happening.
I'm not aware of using any C bindings at all, although I am linking
against the Unix library. My final executable does contain
definitions of caml_alloc_custom, caml_register_custom_operations, and
related functions, but none of my .o or .a files refers to such a
function.
Any ideas how I might track down the source of a custom block?
Norman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] trouble with Marshal.to_string
2005-10-08 16:35 ` Norman Ramsey
@ 2005-10-08 16:57 ` Anil Madhavapeddy
2005-10-08 18:47 ` Norman Ramsey
0 siblings, 1 reply; 6+ messages in thread
From: Anil Madhavapeddy @ 2005-10-08 16:57 UTC (permalink / raw)
To: Norman Ramsey; +Cc: caml-list
On 8 Oct 2005, at 17:35, Norman Ramsey wrote:
>> Are you using any C bindings which create custom blocks? That error
>> occurs if your custom block does not define a serialization function
>> (documented here: http://caml.inria.fr/pub/docs/manual-ocaml/
>> manual032.html#s:custom).
>>
>
> Thanks; at least now I have some idea what's happening.
>
> I'm not aware of using any C bindings at all, although I am linking
> against the Unix library. My final executable does contain
> definitions of caml_alloc_custom, caml_register_custom_operations, and
> related functions, but none of my .o or .a files refers to such a
> function.
>
> Any ideas how I might track down the source of a custom block?
The old-fashioned way, with grep :-) I'm sure there are fancier
ways, but...
shock:~/src/ocaml-3.08.4 avsm$ grep -r custom_serialize_def *
byterun/custom.c: ops->serialize = custom_serialize_default;
byterun/custom.h:#define custom_serialize_default NULL
byterun/io.c: custom_serialize_default,
otherlibs/graph/image.c: custom_serialize_default,
otherlibs/systhreads/posix.c: custom_serialize_default,
otherlibs/systhreads/posix.c: custom_serialize_default,
otherlibs/systhreads/posix.c: custom_serialize_default,
otherlibs/systhreads/win32.c: custom_serialize_default,
otherlibs/systhreads/win32.c: custom_serialize_default,
otherlibs/win32graph/draw.c: custom_serialize_default,
otherlibs/win32unix/unixsupport.c: custom_serialize_default,
So it looks like a few functions in the OCaml standard libraries
aren't serializable; notable the systhreads. Are you using threads
in the structures you are marshalling?
Confirmed with a simple test:
let _ =
let x = Thread.create (fun () -> ()) () in
Marshal.to_string x [Marshal.Closures]
$ ocamlopt.opt -c -thread t.ml
$ ocamlopt.opt unix.cmxa threads.cmxa -thread -o t t.ml
$ ./t
Fatal error: exception Invalid_argument("output_value: abstract value
(Custom)")
--
Anil Madhavapeddy http://anil.recoil.org
University of Cambridge http://www.cl.cam.ac.uk
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] trouble with Marshal.to_string
2005-10-08 16:57 ` Anil Madhavapeddy
@ 2005-10-08 18:47 ` Norman Ramsey
2005-10-08 18:59 ` Thomas Fischbacher
0 siblings, 1 reply; 6+ messages in thread
From: Norman Ramsey @ 2005-10-08 18:47 UTC (permalink / raw)
To: Anil Madhavapeddy; +Cc: caml-list
> > Any ideas how I might track down the source of a custom block?
>
> The old-fashioned way, with grep :-) I'm sure there are fancier
> ways, but...
>
> shock:~/src/ocaml-3.08.4 avsm$ grep -r custom_serialize_def *
> byterun/custom.c: ops->serialize = custom_serialize_default;
> byterun/custom.h:#define custom_serialize_default NULL
> byterun/io.c: custom_serialize_default,
Aha! It seems possible that a closure has captured an open file handle...
Norman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] trouble with Marshal.to_string
2005-10-08 18:47 ` Norman Ramsey
@ 2005-10-08 18:59 ` Thomas Fischbacher
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Fischbacher @ 2005-10-08 18:59 UTC (permalink / raw)
To: Norman Ramsey; +Cc: Anil Madhavapeddy, caml-list
On Sat, 8 Oct 2005, Norman Ramsey wrote:
> Aha! It seems possible that a closure has captured an open file handle...
Better abstain from serializing closures with ocaml anyway.
--
regards, tf@cip.physik.uni-muenchen.de (o_
Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\
(lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_
(if (= x 0) y (g g (- x 1) (* x y)))) n 1)) (Debian GNU)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-10-08 18:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-08 15:34 trouble with Marshal.to_string Norman Ramsey
2005-10-08 16:09 ` [Caml-list] " Anil Madhavapeddy
2005-10-08 16:35 ` Norman Ramsey
2005-10-08 16:57 ` Anil Madhavapeddy
2005-10-08 18:47 ` Norman Ramsey
2005-10-08 18:59 ` Thomas Fischbacher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox