Search Unity

Trivial TcpClient usage causes editor to crash - help?

Discussion in 'Multiplayer' started by MichaelDGagnon, Apr 28, 2015.

  1. MichaelDGagnon

    MichaelDGagnon

    Joined:
    Mar 29, 2013
    Posts:
    2
    I have this really trivial minimal-repro code attached to a camera in an empty scene. This is the whole project. It just connects a tcp socket and that is all; it does not even attempt to look at or handle any changes in the state.
    This crash occurs when the other side of the socket happened to write data. It doesn't matter what the server side looks like - it's just something on the other end of my socket pushing data, who cares.

    What am I missing here? Help :(

    Full client code is the following:

    using UnityEngine;
    using System.Net.Sockets;

    public class CliSocketTest : MonoBehaviour {
    TcpClient client = new TcpClient();

    void Start () {
    client.Connect("127.0.0.1", 7101);
    }
    }


    -----------------
    Note:
    Upgraded to Unity5 and now it spawns a Crash uploader when it crashes. Also attaches a minidump automatically. It's getting an access violation internally in Unity.exe. I immediately have to conclude this is a Unity bug (though it may be exercised by something dumb I'm doing, but that'd be completely besides the point).

    ...
    Unity.exe caused an Access Violation (0xc0000005)
    in module Unity.exe at 0033:40d88190.
    ...
    Read from location ffffffff caused an access violation.
    ...
     

    Attached Files:

    Last edited: Apr 28, 2015
  2. MichaelDGagnon

    MichaelDGagnon

    Joined:
    Mar 29, 2013
    Posts:
    2
    To my enormous confusion, I find that my server gets 2 connections when I run this. To confuse me even more, my server gets 1 connection if I restart unity, create a new project, and immediately press play. That also crashes unity. Woah.

    If I switch the port my server listens on... crashes stop. If I change the trivial client code above to use a different port, it works fine.

    Maybe 7101 is a magic port unity internally tries to connect on for its own business and gets confused/crashes when that connection succeeds and it isn't whatever it hoped it was. And maybe I was unlucky (1 in 65535) and picked the 1 port I shouldn't have picked.

    I don't know.

    I'm going to put on my "let's pretend that didn't happen" blinders and go on my way.