Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] threads
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] threads
> Is anyone using native threads in Ocaml 3.04 intensively on Linux these
> days ?

We occasionally get bug reports similar to yours, under Linux.  It's
hard to say whether it's a bug in the OCaml system thread library, or
in LinuxThreads itself.

> The program "hangs", ps looks like this. Looks like a thread is stuck.
> 
> 18964 pts/3    S      0:00 ./camella.opt
> 18965 pts/3    Z      0:00 [camella.opt <defunct>]
> 18967 pts/3    S      0:00 ./camella.opt

Actually, it looks like the thread manager thread (PID N+1, where N is
the initial PID of the program) died.  It should not, and it is not
surprising that the program hangs, since once the thread manager is
gone the program can no longer create new threads.

> I'm playing with a Gnutella servent, and I'm experimenting crashes
> (bytecode and native).
> I'm using the unix library heavily. So far, I'm aware that the DNS calls
> are not reentrant, but the rest of the library calls should be okay.

Yes, that's another issue: OCaml allows several threads to call
Unix.gethostbyname concurrently (without holding the master mutex),
yet most if not all implementations of gethostbyname() are not
reentrant.

As Nikolaj Bjorner mentioned, some systems provide a reentrant
gethostbyname_r() function, not necessarily with the same interface,
though, making it very hard to use in the Unix library.

(An easy way to see if your problems are related to gethostbyname is
to protect calls to Unix.gethostbyname by a mutex, to ensure that only
one at a time is performed.)

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners