[Mono-bugs] [Bug 541492] New: TcpListener.AcceptSocket() sometimes throw ThreadAbortedException after listener is stopped

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Sep 23 14:32:09 EDT 2009


           Summary: TcpListener.AcceptSocket() sometimes throw
                    ThreadAbortedException after listener is stopped
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: x86-64
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: oskar.berggren at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:
Gecko/2009090217 Ubuntu/9.04 (jaunty) Firefox/3.0.14

I have code that starts a TcpListener, and then calls AcceptSocket() on it.
Another thread then comes along and calls Stop() on the listener.

On MS .Net this seems to cause AcceptSocket() to throw a SocketException, with
error code indicating interrupted system call. It seems difficult to find clear
documentation on how this issue should work, but the mentioned behavior seems

On Mono, I have also experienced the described SocketException, but very often
I seem to get a ThreadAbortedException instead, with the following stack trace:

System.Threading.ThreadAbortException: Thread was being aborted
  at (wrapper managed-to-native)
System.ComponentModel.Win32Exception:W32ErrorMessage (int)
  at System.ComponentModel.Win32Exception..ctor (Int32 error) [0x00000] in
  at System.Net.Sockets.SocketException..ctor (Int32 error) [0x00000] in
  at System.Net.Sockets.Socket.Accept () [0x000b8] in
  at System.Net.Sockets.TcpListener.AcceptSocket () [0x00016] in
  at XXX.TriggerServer.Run_impl () [0x0003b] in MYCODE
  at XXX.TriggerServer.Run () [0x00000] in MYCODE

This makes it difficult to detect and ignore an expected exception while
shutting down the listener, while not ignoring too much.

Reproducible: Always

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list