question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test failures due to System.InvalidOperationException : Memory pool with active blocks is being disposed, 302 of 303 returned

See original GitHub issue

I can pretty regularly reproduce test failures running the components tests with this message by running the tests in the components solution under the debugger.

 Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.LocalizationTest.CanSetCultureAndReadLocalizedResources(culture: "en-US", message: "Hello!")
   Source: LocalizationTest.cs line 38

Outcomes
   1 Passed
   1 Failed

Results

    1)  Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.LocalizationTest.CanSetCultureAndReadLocalizedResources(culture: "en-US", message: "Hello!")
      Duration: 29 sec

    2)  Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.LocalizationTest.CanSetCultureAndReadLocalizedResources(culture: "en-US", message: "Hello!")
      Duration: 1 ms

      Message: 
        [Test Class Cleanup Failure (Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.LocalizationTest)]: System.InvalidOperationException : Memory pool with active blocks is being disposed, 302 of 303 returned
      Stack Trace: 
        MemoryPoolThrowHelper.ThrowInvalidOperationException_DisposingPoolWithActiveBlocks(Int32 returned, Int32 total, DiagnosticPoolBlock[] blocks) line 62
        DiagnosticMemoryPool.Dispose(Boolean disposing) line 119
        MemoryPool`1.Dispose()
        SocketConnectionListener.DisposeAsync() line 144
        KestrelServer.StopAsync(CancellationToken cancellationToken) line 190
        KestrelServer.StopAsync(CancellationToken cancellationToken) line 162
        KestrelServer.Dispose() line 211
        ServiceProviderEngineScope.DisposeAsync()
        --- End of stack trace from previous location where exception was thrown ---
        WebHost.DisposeServiceProviderAsync(IServiceProvider serviceProvider) line 384
        WebHost.DisposeAsync() line 375
        WebHost.Dispose() line 358
        WebHostServerFixture.Dispose() line 27
        ToggleExecutionModeServerFixture`1.Dispose() line 61

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:20 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
halter73commented, Dec 30, 2020

@sh-erfan Do you have any logs? This is expected behavior if an ongoing request takes longer than the ShutdownTimeout (defaults to 5 seconds). You can use IHostApplicationLifetime.ApplicationStopping to observe this and cancel the request gracefully before the timeout.

Even after the ShutdownTimeout expires, Kestrel gives another (nonconfigurable) 1 second grace period after closing all its sockets before it disposes the memory pool. In many cases this is enough time for middleware to observe an IOException and exit, but that is definitely not guaranteed to work. For example, middleware doing some operation that takes over 6 seconds before first writing to a response or middleware delaying over a second between writing without observing ApplicationStopping could run into this MemoryPool ODE.

0reactions
adityamandaleekacommented, Jul 14, 2021

Closing for now… let’s see if this happens again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot access a disposed object. Object name: ' ...
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'MemoryPool'. at System.Buffers.MemoryPoolThrowHelper.
Read more >
https://raw.githubusercontent.com/dotnet/samples/m...
377 area-System.Text Regex tests intermittently fail due to memory usage "In RegexLangElementsCoverageTests.cs, there are several checks related to the ...
Read more >
SDK & Release Notes - Photon Fusion
ReleaseInstance being called when nested NetworkObject is despawned/destroyed explicitly (removed in 1.1.3 Nightly 586). The default pool implementation ...
Read more >
man pages section 3: Basic Library Functions
An error condition is indicated by an otherwise impossible returned value. □. Section 3 describes functions found in various libraries, other than those ......
Read more >
Neuron 3.7.0.929
FIX – Neuron ESB Service could shut down with a License failure - Fixed an exception that occurs when the Peregrine Connect license...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found