Giter VIP home page Giter VIP logo

Comments (1)

KumoKyaku avatar KumoKyaku commented on May 23, 2024

Bug已经复现。
为什么只有PoolSegManager才有Bug?
因为只有PoolSegManager的PoolSegManager.Seg是class,才会出现空引用。

怀疑的两个可能性:
1:TryRecv()的 rcv_queue.Count == 0 判断后,var seq = rcv_queue[0]; 执行前,存在其他线程删除了rcv_queue中的元素。
Q:通过代码分析,删除元素只有 UncheckRecv(Span buffer) 中 rcv_queue.RemoveRange(0, count); 一处。并且只在Recv环节调用,并不存在多线程问题。

2: https://source.dot.net/#System.Private.CoreLib/List.cs,203 rcv_queue.Add(seg);环节,是先增加size,后对下标赋值。
是不是有可能,rcv_queue.Count == 0 判断,var seq = rcv_queue[0]; 正好在List.Add中间执行?
直觉上这种可能性很小,但也不是没有。
一个佐证,但不能确定。在rcv_queue.Count == 0 判断,var seq = rcv_queue[0];两句代码之间插入了日志。Console.WriteLine($"rcv_queue TryRecv正在检测 rcv_queue[0]{rcv_queue[0]} ManagedThreadId{System.Threading.Thread.CurrentThread.ManagedThreadId}");
Bug消失了。

为什么sleep/delay 1 不出现Bug?
测试用例中如果delay,正好可以将Add和Recv函数错开调用。

from kcp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.