Problems with openFd and -threaded

2010-11-27 Thread wren ng thornton
So I've just started playing around with STM and -threaded programs and 
I've run into a bug. The bug is similar to [1] except that the file in 
question is a Posix FIFO instead of a Bluetooth device. Same behavior: 
always errors with -threaded, but expected behavior when not -threaded 
(i.e., blocks until another process opens the other end of the FIFO). 
GHC version is 6.12.1.


In the previous thread Simon confirmed that it's a bug and said he'd fix 
it, but I didn't see any ticket mentioned. Does anyone know if there's a 
ticket for it, or when it will be/has been fixed?



[1] 
http://www.haskell.org/pipermail/glasgow-haskell-users/2009-December/018147.html


--
Live well,
~wren
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Problems with openFd and -threaded

2010-11-29 Thread Bryan O'Sullivan
On Sat, Nov 27, 2010 at 9:05 PM, wren ng thornton  wrote:

> So I've just started playing around with STM and -threaded programs and
> I've run into a bug. The bug is similar to [1] except that the file in
> question is a Posix FIFO instead of a Bluetooth device. Same behavior:
> always errors with -threaded, but expected behavior when not -threaded
> (i.e., blocks until another process opens the other end of the FIFO). GHC
> version is 6.12.1.
>

Isn't that pretty normal? Just retry if you get EINTR, that's what
throwErrnoIfMinus1 and friends are for:

http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Foreign-C-Error.html#v%3AthrowErrnoIfRetryMayBlock
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Problems with openFd and -threaded

2010-11-29 Thread wren ng thornton

On 11/29/10 6:36 PM, Bryan O'Sullivan wrote:

On Sat, Nov 27, 2010 at 9:05 PM, wren ng thornton  wrote:


So I've just started playing around with STM and -threaded programs and
I've run into a bug. The bug is similar to [1] except that the file in
question is a Posix FIFO instead of a Bluetooth device. Same behavior:
always errors with -threaded, but expected behavior when not -threaded
(i.e., blocks until another process opens the other end of the FIFO). GHC
version is 6.12.1.


Isn't that pretty normal?


The blocking for someone to open the other end is perfectly normal. The 
fact that compiling with -threaded takes a perfectly working program and 
makes it consistently crash I wouldn't call "normal".


N.B., the call to openFd in question is from the main thread and before 
any STM or forkIO shenanigans.




Just retry if you get EINTR, that's what
throwErrnoIfMinus1 and friends are for:

http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Foreign-C-Error.html#v%3AthrowErrnoIfRetryMayBlock


I'll see if I can make a workaround with that, but as I said: Simon's 
already confirmed that this is a bug, I'm just looking for a ticket 
number or a version where it's fixed.


--
Live well,
~wren
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Problems with openFd and -threaded

2010-11-29 Thread Bryan O'Sullivan
On Mon, Nov 29, 2010 at 9:49 PM, wren ng thornton  wrote:

> Isn't that pretty normal?
>>
>
> The blocking for someone to open the other end is perfectly normal. The
> fact that compiling with -threaded takes a perfectly working program and
> makes it consistently crash I wouldn't call "normal".
>

Actually, this happens all the time if you're calling a system call that
isn't already wrapped for you, and the behaviour is expected: you absolutely
must expect, and deal with, EINTR. Here's an example:
http://www.serpentine.com/blog/2010/09/04/dealing-with-fragile-c-libraries-e-g-mysql-from-haskell/

Are you using System.Posix.IO.openFD? The check for EINTR wasn't added to
the unix package until January of this year, so perhaps the version of GHC
or the unix package that you're using is too old to contain the fix?


> N.B., the call to openFd in question is from the main thread and before any
> STM or forkIO shenanigans.


That doesn't matter. Once the threaded RTS starts, it's going to send your
program SIGVTALRM.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Problems with openFd and -threaded

2010-11-30 Thread Simon Marlow

On 30/11/10 05:49, wren ng thornton wrote:

On 11/29/10 6:36 PM, Bryan O'Sullivan wrote:

On Sat, Nov 27, 2010 at 9:05 PM, wren ng thornton
wrote:


So I've just started playing around with STM and -threaded programs and
I've run into a bug. The bug is similar to [1] except that the file in
question is a Posix FIFO instead of a Bluetooth device. Same behavior:
always errors with -threaded, but expected behavior when not -threaded
(i.e., blocks until another process opens the other end of the FIFO).
GHC
version is 6.12.1.


Isn't that pretty normal?


The blocking for someone to open the other end is perfectly normal. The
fact that compiling with -threaded takes a perfectly working program and
makes it consistently crash I wouldn't call "normal".

N.B., the call to openFd in question is from the main thread and before
any STM or forkIO shenanigans.



Just retry if you get EINTR, that's what
throwErrnoIfMinus1 and friends are for:

http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Foreign-C-Error.html#v%3AthrowErrnoIfRetryMayBlock



I'll see if I can make a workaround with that, but as I said: Simon's
already confirmed that this is a bug, I'm just looking for a ticket
number or a version where it's fixed.


And fix it I did:

Wed Jan 27 11:46:00 GMT 2010  Simon Marlow 
  * check for EINTR in openFd

M ./System/Posix/Error.hs -2 +26
M ./System/Posix/IO.hsc -1 +1

The fix is in unix-2.4.1.0, which comes with GHC 7.0.1.

Cheers,
Simon

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


Re: Problems with openFd and -threaded

2010-11-30 Thread wren ng thornton

On 11/30/10 11:05 AM, Simon Marlow wrote:

On 30/11/10 05:49, wren ng thornton wrote:

I'll see if I can make a workaround with that, but as I said: Simon's
already confirmed that this is a bug, I'm just looking for a ticket
number or a version where it's fixed.


And fix it I did:

Wed Jan 27 11:46:00 GMT 2010 Simon Marlow 
* check for EINTR in openFd

M ./System/Posix/Error.hs -2 +26
M ./System/Posix/IO.hsc -1 +1

The fix is in unix-2.4.1.0, which comes with GHC 7.0.1.


Cool. Thanks.

--
Live well,
~wren

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


Re: Problems with openFd and -threaded

2010-12-03 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/29/10 18:36 , Bryan O'Sullivan wrote:
> On Sat, Nov 27, 2010 at 9:05 PM, wren ng thornton  > wrote:
> 
> So I've just started playing around with STM and -threaded programs and
> I've run into a bug. The bug is similar to [1] except that the file in
> question is a Posix FIFO instead of a Bluetooth device. Same behavior:
> always errors with -threaded, but expected behavior when not -threaded
> (i.e., blocks until another process opens the other end of the FIFO).
> GHC version is 6.12.1.
> 
> Isn't that pretty normal? Just retry if you get EINTR, that's what
> throwErrnoIfMinus1 and friends are for:

The problem is the interrupting signal is the timer interrupt used by the
runtime system; this should not be visible to user programs, instead the
runtime should *itself* restart the operation.

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]  allb...@kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university  KF8NH
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz5Uv4ACgkQIn7hlCsL25UOLACgz85SXrIH54c5zVZHot0FTzqW
Z9cAoKa6ViYVrT4U5PaYwVF34oM6lahv
=o2md
-END PGP SIGNATURE-

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