RE: [Haskell-cafe] Project postmortem

2005-12-02 Thread Simon Marlow
On 21 November 2005 10:16, Joel Reymont wrote:

 Is Wolfgang still around?
 
 Would you guys be willing to guide me through this? I could then
 possibly become the next Mac OSX expert :-).
 
 I have the disassembler dumps, etc. I do not know how to approach
 this problem. I read up a bit on the GHC internals, STG, code
 generation, etc.

If anyone is interested, this turned out to be a bug in the Network.BSD
module, namely that getHostByName isn't thread safe because it is based
on the C library function gethostbyname(), which returns data in a
single static area.

Workarounds are:

  - do your own mutual exclusion locking around getHostByName and any
function that calls it (eg. connectTo).

  - use Network.Alt (http://www.cs.helsinki.fi/u/ekarttun/network-alt/),
which has a thread-safe implementation of getHostByName.

  - wait for 6.4.2, which will contain a fix for this bug (we don't have
a fix committed yet, Einar Karttunen has kindly offered to look into
it).

Cheers,
Simon
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [Haskell-cafe] Project postmortem

2005-12-02 Thread Tomasz Zielonka
On Fri, Dec 02, 2005 at 11:20:54AM -, Simon Marlow wrote:
 If anyone is interested, this turned out to be a bug in the Network.BSD
 module, namely that getHostByName isn't thread safe because it is based
 on the C library function gethostbyname(), which returns data in a
 single static area.
 
 Workarounds are:
 
   - do your own mutual exclusion locking around getHostByName and any
 function that calls it (eg. connectTo).
 
   - use Network.Alt (http://www.cs.helsinki.fi/u/ekarttun/network-alt/),
 which has a thread-safe implementation of getHostByName.
 
   - wait for 6.4.2, which will contain a fix for this bug (we don't have
 a fix committed yet, Einar Karttunen has kindly offered to look into
 it).

Do I understand correctly that another workaround is
- don't compile your programs with -threaded
?

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [Haskell-cafe] Project postmortem

2005-12-02 Thread Joel Reymont
I thought that if -threaded is not used then all the blocking IO is  
assigned a separate OS thread.


On Dec 2, 2005, at 12:10 PM, Tomasz Zielonka wrote:


Do I understand correctly that another workaround is
- don't compile your programs with -threaded
?



--
http://wagerlabs.com/





___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


RE: [Haskell-cafe] Project postmortem

2005-12-02 Thread Simon Marlow
On 02 December 2005 12:11, Tomasz Zielonka wrote:

 On Fri, Dec 02, 2005 at 11:20:54AM -, Simon Marlow wrote:
 If anyone is interested, this turned out to be a bug in the
 Network.BSD module, namely that getHostByName isn't thread safe
 because it is based on the C library function gethostbyname(), which
 returns data in a single static area. 
 
 Workarounds are:
 
   - do your own mutual exclusion locking around getHostByName and any
 function that calls it (eg. connectTo).
 
   - use Network.Alt
 (http://www.cs.helsinki.fi/u/ekarttun/network-alt/), which has a
 thread-safe implementation of getHostByName. 
 
   - wait for 6.4.2, which will contain a fix for this bug (we don't
 have a fix committed yet, Einar Karttunen has kindly offered to
 look into it).
 
 Do I understand correctly that another workaround is
 - don't compile your programs with -threaded
 ?

No, the bug isn't related to -threaded.  It still occurs without
-threaded.

Cheers,
Simon
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [Haskell-cafe] Project postmortem

2005-12-02 Thread Tomasz Zielonka
On Fri, Dec 02, 2005 at 12:39:25PM -, Simon Marlow wrote:
  Do I understand correctly that another workaround is
  - don't compile your programs with -threaded
  ?
 
 No, the bug isn't related to -threaded.  It still occurs without
 -threaded.

Let's check that now I understand - so the sequence 

call gethostbyname
read the returned hostent

is written in Haskell, and many such sequences can be interleaved when
using Concurrent Haskell?

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


RE: [Haskell-cafe] Project postmortem

2005-12-02 Thread Simon Marlow
On 02 December 2005 12:49, Tomasz Zielonka wrote:

 On Fri, Dec 02, 2005 at 12:39:25PM -, Simon Marlow wrote:
 Do I understand correctly that another workaround is
 - don't compile your programs with -threaded
 ?
 
 No, the bug isn't related to -threaded.  It still occurs without
 -threaded.
 
 Let's check that now I understand - so the sequence
 
 call gethostbyname
 read the returned hostent
 
 is written in Haskell, and many such sequences can be interleaved when
 using Concurrent Haskell?

Yes, exactly.

Cheers,
Simon
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


RE: [Haskell-cafe] Project postmortem

2005-12-02 Thread Simon Marlow
On 02 December 2005 12:25, Joel Reymont wrote:

 I thought that if -threaded is not used then all the blocking IO is
 assigned a separate OS thread.

No - the runtime is completely single-threaded without -threaded.
Blocking I/O is managed by the runtime.  With -threaded, blocking I/O is
managed by a Haskell thread.  The programmer shouldn't see any
difference in the behaviour of I/O.

Is the documentation for -threaded lacking?  I realise it's a bit terse,
but do you have any concrete suggestions for improving it?

Cheers,
Simon
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs