[Mono-bugs] [Bug 396091] New: async_invoke_io_thread buggy.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri May 30 18:28:58 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=396091


           Summary: async_invoke_io_thread buggy.
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: io-layer
        AssignedTo: dick at novell.com
        ReportedBy: miguel at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


The following sample crashes the Mono runtime, it seems that we are passing
invalid data to our async callback:

  using System;
using System.Collections.Generic;
using System.Threading;
using System.IO;
using System.Net;
using System.Net.Sockets;

public class Tester
  {
    Socket _listenSocket;
    Socket _outgoingSocket;
    Socket _receiveSocket;
    Socket _connected;
    byte[] buffer = new byte[10000];
    byte[] outBuffer = new byte[10000];
    List<ArraySegment<byte>> _list = new List<ArraySegment<byte>>();

static void Main ()
{
new Tester ();
}

    public Tester()
    {
      IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, 44444);
      _listenSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
      _listenSocket.Bind(endpoint);
      _listenSocket.Listen(10);

      _outgoingSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
      _outgoingSocket.Connect("localhost", 44444);
      _connected = _listenSocket.Accept();
      ArraySegment<byte> seg = new ArraySegment<byte>(outBuffer, 0, 10);
      _list.Add(seg);
      _connected.BeginReceive(_list, SocketFlags.None, OnReceiveComplete,
_connected);
      _outgoingSocket.BeginSend(buffer, 0, 0, SocketFlags.None,
OnSendComplete, null);
      SocketError err;
      _outgoingSocket.Send(outBuffer, 0, 10, SocketFlags.None, out err);
      Thread.Sleep(1000);
    }

    public void OnReceiveComplete(IAsyncResult ar)
    {
      // This NEVER gets called.
      Console.WriteLine("OnReceiveComplete");
      int bytesReceived = _connected.EndReceive(ar);
      Console.WriteLine("Bytes received: {0}", bytesReceived);

    }

    public void OnSendComplete(IAsyncResult ar)
    {
      // This does get called.
      Console.WriteLine("OnSendComplete");
      int bytesSent = _outgoingSocket.EndSend(ar);


    }

  }


Compile with gmcs


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


More information about the mono-bugs mailing list