mheyman / Isopoh.Cryptography.Argon2

Fully managed .Net Core implementation of Argon2
Other
196 stars 9 forks source link

Memory leak #8

Closed Wintereise closed 6 years ago

Wintereise commented 6 years ago

Sample code:

using System;
using Isopoh.Cryptography.Argon2;

namespace SnippetTester
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i <= 1000000; i++)
            {
                Console.WriteLine("Argon2 (b,b) is: " + Argon2.Verify("$argon2i$v=19$m=65536,t=3,p=1$M2f6+jnVc4dyL3BfMQRzoA==$jO/fOrgqxX90XDVhiYZgIVJJcw0lzIXtRFRCEggXYV8=", "b"));
            }
        }
    }
}

Expected: things work ok, without ballooning to take up all system memory.

Actually:

image

What's in the heap (around 5GB allocated at this stage:)

image

mheyman commented 6 years ago

Good catch! It took me a while to track it down. There was also an associated (but not directly associated) lock leak which I consider a little bit worse. Fixed with a unit test in version 1.0.5.