Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2002-03-22 (14:55)
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

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 Archives:
Bug reports: FAQ:
Beginner's list: