StackOverflowException in SuperSocket

Jan 30, 2014 at 7:25 AM
Edited Jan 30, 2014 at 8:30 AM
Hi. I'm using SuperWebSocket from source. Sometimes it crashes with stack overflow. Last two repeating lines from stack trace:
SuperSocket.SocketEngine.dll!SuperSocket.SocketEngine.AsyncSocketSession.OnSendingCompleted(object sender, System.Net.Sockets.SocketAsyncEventArgs e = {System.Net.Sockets.SocketAsyncEventArgs})
SuperSocket.SocketEngine.dll!SuperSocket.SocketEngine.AsyncSocketSession.SendAsync(SuperSocket.Common.SendingQueue queue = {SuperSocket.Common.SendingQueue})
repeating log line:
0 of 355 were transferred, send the rest 355 bytes right now.
part of SendAsync code (using ILSpy):
Socket client = base.Client;
if (client == null)
{
    base.OnSendError(queue, CloseReason.SocketError);
}
else
{
    if (!client.SendAsync(this.m_SocketEventArgSend))
    {
        this.OnSendingCompleted(client, this.m_SocketEventArgSend);
    }
}
part of OnSendingCompleted code:
SendingQueue sendingQueue = e.UserToken as SendingQueue;
int num = sendingQueue.Sum((ArraySegment<byte> q) => q.Count);
if (num != e.BytesTransferred)
{
    sendingQueue.InternalTrim(e.BytesTransferred);
    base.AppSession.Logger.InfoFormat("{0} of {1} were transferred, send the rest {2} bytes right now.", e.BytesTransferred, num, sendingQueue.Sum((ArraySegment<byte> q) => q.Count));
    this.ClearPrevSendState(e);
    this.SendAsync(sendingQueue);
    return;
}
So it can't send data (without any other error messages) and endlessly repeating recursive calls to SendAsync.
It uses SuperSocket version 1.6.1, which i can't find at SuperSocket downloads.
Coordinator
Jan 30, 2014 at 5:36 PM
Ok,it seems a bug of 1.6, i'll fix it on these days. You also can find the source code of 1.6.1 from the branch 1.6 of SuperSocket.
Marked as answer by sk2a on 1/30/2014 at 8:17 PM
Coordinator
Jan 31, 2014 at 9:43 AM
Hello, thank you very much!

I have fixed it just now. The SuperSocket in the SuperWebSocket reference folder also has been updated.