[ ghc-Bugs-1219920 ] socketToHandle,
hGetContents cause errors in ghci
SourceForge.net
noreply at sourceforge.net
Mon Jun 13 15:34:25 EDT 2005
Bugs item #1219920, was opened at 2005-06-13 14:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1219920&group_id=8032
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Andrew Pimlott (pimlott)
Assigned to: Nobody/Anonymous (nobody)
Summary: socketToHandle, hGetContents cause errors in ghci
Initial Comment:
I wrote a server using socketToHandle and hGetContents.
The first request worked fine, but the second request
crashed with "internal error: scavenge_stack: weird
activation record found on stack: 9". I tried to
create a test case. I couldn't reproduce the same
problem, but I did get an intermittent "Bad file
descriptor". I think it may be a related problem, and
it may have to do with garbage collection (based on a
strace showing a call to getrusage).
The program is below, and when I run it with runghc and
feed it a line of input with nc, it crashes on the 17th
request. It's not important to me that you fix it; in
fact I only tried this as an experiment to simplify
some working code. But if you would like more
information, let me know.
I am using the Debian package ghc6 6.4-4.
import Network.Socket
import System.IO
main = do
s <- socket AF_INET Stream 0
h <- inet_addr "127.0.0.1"
bindSocket s (SockAddrInet 1236 h)
listen s 5
loop s
loop listenSock = do
(s,_) <- accept listenSock
h <- socketToHandle s ReadMode
input <- hGetContents h
putStrLn (take 10 input)
send s "got it\n"
sClose s
loop listenSock
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1219920&group_id=8032
More information about the Glasgow-haskell-bugs
mailing list