#4514: System.Timeout cannot properly cancel IO actions with new IO manager
---------------------------------+------------------------------------------
Reporter: adept | Owner: tibbe
Type: bug | Status: new
Priority: normal | Component: Runtime System
Version: 7.0.1 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Incorrect result at runtime
---------------------------------+------------------------------------------
Comment(by adept):
Here is what I've found via the combination of debug output and creative
strace use. Allow me to present you an annotated and abbreviated "strace"
output:
{{{
31628 accept(8, {sa_family=AF_INET, sin_port=htons(33312),
sin_addr=inet_addr("127.0.0.1")}, [16]) = 11
31628 fcntl64(11, F_GETFL) = 0x2 (flags O_RDWR)
31628 fcntl64(11, F_SETFL, O_RDWR|O_NONBLOCK) = 0
So, connection is accepted and socket 11 is created for
communication with "other side".
I will send "1", then "2", then "FINISH" and allow process to time
out.
31630 recv(11, <unfinished ...>
31630 epoll_ctl(3, EPOLL_CTL_ADD, 11, {EPOLLIN, {u32=11, u64=11}}
<unfinished ...>
As no data is available initially, epoll callback is set up on FD
11.
31629 <... epoll_wait resumed> {{EPOLLIN, {u32=11, u64=11}}}, 64, 4684) =
1
31629 epoll_ctl(3, EPOLL_CTL_DEL, 11, {0, {u32=11, u64=2814754062073867}})
= 0
31630 recv(11, "1\r\n", 1000, 0) = 3
As soon as data is available, callback is removed, data is read.
31630 send(11, "1\r\n", 3, 0) = 3
31630 recv(11, <unfinished ...>
31630 epoll_ctl(3, EPOLL_CTL_ADD, 11, {EPOLLIN, {u32=11,
u64=13202238110760435723}}) = 0
31629 <... epoll_wait resumed> {{EPOLLIN, {u32=11,
u64=13202238110760435723}}}, 64, 4043) = 1
31629 epoll_ctl(3, EPOLL_CTL_DEL, 11, {0, {u32=11,
u64=13201934143039995915}}) = 0
31630 recv(11, "2\r\n", 1000, 0) = 3
31630 send(11, "2\r\n", 3, 0) = 3
31630 recv(11, <unfinished ...>
31630 epoll_ctl(3, EPOLL_CTL_ADD, 11, {EPOLLIN, {u32=11, u64=17179869195}}
<unfinished ...>
31629 <... epoll_wait resumed> {{EPOLLIN, {u32=11, u64=17179869195}}}, 64,
2011) = 1
31629 epoll_ctl(3, EPOLL_CTL_DEL, 11, {0, {u32=11,
u64=13201950773153366027}}) = 0
31630 recv(11, "FINISH\r\n", 1000, 0) = 8
31630 send(11, "FINISH\r\n", 8, 0) = 8
31630 recv(11, 0xb73670f0, 1000, 0) = -1 EAGAIN (Resource temporarily
unavailable)
31630 epoll_ctl(3, EPOLL_CTL_ADD, 11, {EPOLLIN, {u32=11,
u64=34359738379}}) = 0
Here I allow read to time out.
Notice that there are no calls to epoll_ctl(3, EPOLL_CTL_DEL, 11,
...)
31630 close(11) = 0
Timeout fires up, socket is closed, my telnet is terminatin at this
point.
31628 accept(8, {sa_family=AF_INET, sin_port=htons(33313),
sin_addr=inet_addr("127.0.0.1")}, [16]) = 11
31628 fcntl64(11, F_GETFL) = 0x2 (flags O_RDWR)
31628 fcntl64(11, F_SETFL, O_RDWR|O_NONBLOCK) = 0
I connect again. Socket/FD 11 is allocated.
31630 recv(11, 0xb737c110, 1000, 0) = -1 EAGAIN (Resource temporarily
unavailable)
Since I am not as fast as "recv", it sees no data.
One would expect epoll_ctl(3, EPOLL_CTL_ADD, 11, ...) at this point,
but it
never comes.
Eventually, timeout fires up and socket is closed.
31630 close(11) = 0
}}}
Now, I don't know enough about epoll and System.Event.Thread (yet), but
absence of EPOLL_CTL_DEL before the first close(11) looks suspicious. What
would you say?
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4514#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs