Version française
Home     About     Download     Resources     Contact us    
Browse thread
Why is marshalling not thread-safe? (2.04)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gerd Stolpmann <Gerd.Stolpmann@d...>
Subject: Why is marshalling not thread-safe? (2.04)
Hi,

I'm currently writing a multi-threaded server which communicates with its
clients by O'caml's marshalling module. After some segfaults I found out that
the output_value and input_value primitives are not thread-safe, because there
are some global variables (extern_table, intern_input) for which there is only
one instance for all threads. (The segfaults happened when one of these
variables was freed.)

The code contains some mutexes, but these mutexes only protect the structures
of the channels, and not these global variables. So I think that thread-safety
was intended but never checked, am I right?

At the first glance, there seems to be a simple solution of the problem,
because it is possible to avoid these global variables and pass them as
arguments to the functions needing them. But I did not check this in detail.

Is it possible to get marshalling reentrant? A multi-threaded server is more
or less senseless if marshalling is serialized.

Gerd
-- 
----------------------------------------------------------------------------
Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 100             
64293 Darmstadt     EMail:   Gerd.Stolpmann@darmstadt.netsurf.de (privat)
Germany                     
----------------------------------------------------------------------------