Re: schedule: re-entered unsafely - with heavy concurrent load

2005-02-19 Thread Einar Karttunen
Simon Marlow [EMAIL PROTECTED] writes:
 I fixed a bug that might cause this in the last couple of days.  Could
 you try again with a fresh build and let us know if the problem still
 occurs?

Seems to work without problems on 6.4.20050218. GHC seems to improve
faster than one can spot problems :-)

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


schedule: re-entered unsafely - with heavy concurrent load

2005-02-18 Thread Einar Karttunen
Hello

I am having problems with the threaded rts (6.5.20050207)
dying with 'schedule: re-entered unsafely'. The same code 
seems to work with 6.2.2 with threaded rts.

The exact error message is:
foo: schedule: re-entered unsafely.
   Perhaps a 'foreign import unsafe' should be 'safe'?

I originally notices the problem with networking code which 
didn't use any of Network (nor threadWaitX). However the error 
appeared even with the standard libraries tipping in the direction 
of a bug in the rts.

The code works most of the time, but has a small probability of 
failing when load is high. The test case implements a dummy web 
server which can be tried with e.g. apache benchmark (ab),
/usr/sbin/ab2 -c 1000 -n 5000 127.0.0.1:8080/foo
usually crashes the code when run a few times.
The code should be compiled and run as 
ghc --make -threaded foo.hs -o foo  ./foo 8080

import Network
import Control.Concurrent
import qualified Control.Exception as E
import System
import System.IO

main = do [port] - getArgs
  server port

server port = do
  s - listenOn $ PortNumber $ fromIntegral $ read port
  acceptLoop s

acceptLoop sock = do
  (csock,_,_) - accept sock
  forkIO (handle csock `E.catch` print)
  acceptLoop sock

handle sock = do
  hPutStr sock HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\n
  hPutStr sock (This is the body for the request to\n++hope you like 
this.\n\nnow garbage:\n)
  hClose sock


- Einar Karttunen

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


RE: schedule: re-entered unsafely - with heavy concurrent load

2005-02-18 Thread Simon Marlow
On 18 February 2005 22:15, Einar Karttunen wrote:

 I am having problems with the threaded rts (6.5.20050207)
 dying with 'schedule: re-entered unsafely'. The same code
 seems to work with 6.2.2 with threaded rts.
 
 The exact error message is:
 foo: schedule: re-entered unsafely.
Perhaps a 'foreign import unsafe' should be 'safe'?

I fixed a bug that might cause this in the last couple of days.  Could
you try again with a fresh build and let us know if the problem still
occurs?

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