English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Marshaling of custom blocks and threads
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-12-03 (22:06)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: Marshaling of custom blocks and threads
> Can s/o please confirm whether the module Marshal (and especially its
> usage to serialize custom blocks) is thread-safe in Ocaml 3.0 ?
> I remember reading sth about a pb with bytecode threads and marshaling
> in a previous version of Ocaml but cannot determine surely whether
> the pb has been fixed since.

With bytecode threads, there is an issue with Marshal.{to,from}_channel,
which can raise a spurious Sys_blocked_io exception.  This problem is
still in 3.00, and will be corrected in the next release.

With system threads, as Gerd Stolpmann said, there used to be a race
condition bug in Marshal.to_string, but it is fixed in 3.00.

Finally, there is a bug in marshalling of custom objects in 3.00.
Manuel Fahndrich posted a fix, which is now in the working sources.

> The reason i ask follows :  i have a program with (bytecode) threads
> exchanging data (float arrays)  with Marshal.to_string/ThreadUnix.write and
> ThreadUnix.read/Marshal.from_string.

Shoud be OK if you apply Manuel's patch.  If it still crashes, I'd be
interested in a test program that reproduces the crash.

In a previous mail, you asked:

> Just to know - before i start the work : is there any plans or work 
> undergoing for integrating the support for Ocaml3.0 "custom blocks" in 
> the Camlidl stub code generator ?

I'm not currently working on this, and actually don't have precise
ideas about how to provide support for custom blocks.  If you have
few custom block types to handle, you can always use a typedef with
the "abstract", "c2ml" and "ml2c" attributes pointing to your own
packing/unpacking functions.


- Xavier Leroy