sta / sta/websocket-sharp

StackOverflowException on .Net 6.0

Open
#702 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

I kept running into StackOverflowException when compiled on .Net 6.0, but not .Net 5.0. The issue was mostly happening on fast networks with large packages (1MB). The reason for this was that websocket-sharp uses recursion when receiving packages. After 49 recursions, it ran out of stack memory.

I believe Net6.0 introduced some network optimiazations by increaseing buffers, or similar.

Not sure this is something everyone is exeprienceing, but the recursive architecture is inherently prone to this problem, so I suspect this is going to happen more and more as people switch to Net6.0.

As a possible solution, I will upload a pull request that flattens the receive function.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating websocket-sharp's recursive receive function and reproduce the failure on .NET 6.0 using a fast network and large packages around 1 MB. Done means the receive path no longer exhausts the stack during these transfers; no specific file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.