Skip to content

Hit the Assert in SimpleLeakAwareByteBuffer.CloseLeak #472

Open
@yyjdelete

Description

@yyjdelete

Run the below code, and you can see an false case of leak is reported.
And an Debug.Assert can be seen when run with Debug builds of DotNetty.

@nayato @StormHub Any idea for this?
I think the Retain/Release of IByteBuffer is thread-safe(just don't read/write bytebuf concurrently)?

Use the ExampleHelper from Examples.Common

    internal class Program
    {
        static Program()
        {
            Environment.SetEnvironmentVariable("io.netty.leakDetection.targetRecords", "256");
            DotNetty.Common.ResourceLeakDetector.Level = DotNetty.Common.ResourceLeakDetector.DetectionLevel.Paranoid;
        }

        private static void Main()
        {
            ExampleHelper.SetConsoleLogger();
            {
                var loop = new SingleThreadEventLoop();
                int i = 0;
                do
                {
                    var buf0 = ByteBufferUtil.DefaultAllocator.Buffer();
                    buf0.WriteInt(i);
                    buf0.WriteInt(i);
                    ++i;
                    loop.Schedule(state1 =>
                    {
                        var buf1 = (IByteBuffer)state1;
                        buf1.ReadInt();
                        buf1.Release();
                    }, buf0.RetainedSlice(), TimeSpan.FromMilliseconds(10));
                    buf0.Release();
                    buf0 = null;
                    Thread.Sleep(10);
                }
                while (true);
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions