title: .NET Core: Finally block not called on unhandled exception on Linux
body: <p>I have created the following C# program:</p>
  
  <pre><code>namespace dispose_test
  {
      class Program
      {
          static void Main(string[] args)
          {
              using (var disp = new MyDisposable())
              {
                  throw new Exception("Boom");
              }
          }
      }
  
      public class MyDisposable : IDisposable
      {
          public void Dispose()
          {
              Console.WriteLine("Disposed");
          }
      }
  }
  </code></pre>
  
  <p>When I run this using <code>dotnet run</code>, I see the following behavior:</p>
  
  <ul>
  <li>Windows: Exception text written to console, "Disposed" printed ~20 second later, program exits.</li>
  <li>Linux: Exception text written to console, program exits immediately. "Disposed" never written.</li>
  </ul>
  
  <p><strong>The delay on Windows is annoying, but the fact that Dispose() isn't called at all on Linux is troubling. Is this expected behavior?</strong></p>
  
  <p>EDITS Clarifications/additions from the conversation below:</p>
  
  <ul>
  <li>This is not specific to <code>using/Dispose()</code>, which is just a special case of <code>try/finally</code>. The behavior also occurs generally with <code>try/finally</code> - the <code>finally</code> block is not run. I have updated the title to reflect this.</li>
  <li>I have also checked for the execution of <code>Dispose()</code> by writing a file to the filesystem, just to ensure that problem wasn't related to stdout being disconnected from the console before <code>Dispose()</code> is run in the case of an unhandled exception. Behavior was the same.</li>
  <li><code>Dispose()</code> does get called if the exception is caught anywhere within the application. It's when it goes completely unhandled by the application that this behavior occurs.</li>
  <li>On Windows, the long gap is not due to compilation delay. I started timing when the exception text was written to the console.</li>
  <li>My original experiment was doing <code>dotnet run</code> on both platforms, which means separate compilations, but I have also tried by doing <code>dotnet publish</code> on Windows and directly running the output on both platforms, with the same result. The only difference is that, when run directly on Linux, the text "Aborted (core dumped)" is written after the exception text.</li>
  </ul>
  
  <p>Version details:</p>
  
  <ul>
  <li><code>dotnet --version</code> -> 1.0.4.</li>
  <li>Compiling to netcoreapp1.1, running on .NET Core 1.1.</li>
  <li><code>lsb-release -d</code> -> Ubuntu 16.04.1 LTS</li>
  </ul>