Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

ObjectDisposedException while shutting down #946

Closed
Tragetaschen opened this issue Jun 30, 2016 · 4 comments
Closed

ObjectDisposedException while shutting down #946

Tragetaschen opened this issue Jun 30, 2016 · 4 comments

Comments

@Tragetaschen
Copy link
Contributor

I'm running the RTM bits and got the following stack trace after pressing CTRL+C on the dotnet run command line on Windows:

Unhandled Exception: System.ObjectDisposedException: The SafeHandle was closed.
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.NativeMethods.uv_async_send(UvAsyncHandle handle)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.async_send(UvAsyncHandle handle)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelThread.PostCloseHandle(Action`1 callback, IntPtr handle)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvHandle.ReleaseHandle()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvStreamHandle.ReleaseHandle()
   at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
   at System.Runtime.InteropServices.SafeHandle.Finalize()

By that time, Kestrel had seen two requests on localhost: One for / that sent a context.Response.Redirect('/foo/') and the one for /foo/ that returned a 404.

I cannot reproduce this on subsequent runs.

@Tragetaschen
Copy link
Contributor Author

It also happens just with the 404-request for /foo/

@Tragetaschen
Copy link
Contributor Author

I think the problem is that Autofac as my DI container doesn't provide an IServiceProvider that implements IDisposable. That means the entire application stops by ways of the finalizer.

Isn't the IServiceProvider that's returned from ConfigureServices required to implement IDisposable?

@Tratcher
Copy link
Member

RE: aspnet/DependencyInjection#379

@muratg
Copy link
Contributor

muratg commented Jul 8, 2016

Dup of the DI issue linked above

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants