runtime: Hang possibly related to GC in preview7

The following program is expected to consume 1 full CPU core forever:

        byte[] encryptionData = new byte[16];

        using (var algorithm = new AesManaged())
        {
            algorithm.GenerateKey();
            algorithm.GenerateIV();
            algorithm.Mode = CipherMode.ECB;
            algorithm.Padding = PaddingMode.None;

            var cryptoTransform = algorithm.CreateEncryptor();

            while (true)
            {
                var result = cryptoTransform.TransformFinalBlock(encryptionData, 0, encryptionData.Length);
            }
        }

But sometimes CPU usage stops. The debugger cannot stop the program at that point. Using Process Explorer I captured this stack for the main thread:

image

image

This is Windows 10 and a very recent dbghelp.dll so I don’t understand why the stack is broken.

Reproducing this is a bit brittle. Sometimes, it is enough to start the program and the hang occurs after at most a minute or so. Sometimes, this does not seem to work. But starting PerfView and starting to collect data always leads to a hang within seconds.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Thanks for the confirmation @GSPP! I was about to look into whether the fix made it to the daily build you were using but glad you figured it out : )

Thanks for the dump @GSPP! I found the issue that causes the hang so I’ll be sending out a fix for that tonight.