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

Handle Invalid #336

Closed
benaadams opened this issue Nov 6, 2015 · 4 comments
Closed

Handle Invalid #336

benaadams opened this issue Nov 6, 2015 · 4 comments

Comments

@benaadams
Copy link
Contributor

A handle is getting lost somewhere and either finalised or early disposed; it most often shows up on mono and randomly causes tests to fail; mostly tarvis in but occasionally also happens on appveyor.

Haven't be able to track down the cause

e.g. #335 with the following resilts: https://travis-ci.org/aspnet/KestrelHttpServer/builds/89566455

info: workingdir: test/Microsoft.AspNet.Server.Kestrel.FunctionalTests
Discovering: Microsoft.AspNet.Server.Kestrel.FunctionalTests
Discovered: Microsoft.AspNet.Server.Kestrel.FunctionalTests
Starting: Microsoft.AspNet.Server.Kestrel.FunctionalTests
Stacktrace:
Native stacktrace:
mono() [0x4b23dc]
mono() [0x508a0e]
mono() [0x428fad]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0) [0x7fd272101cb0]
/home/travis/libuvinstall/lib/libuv.so(uv_async_send+0x4) [0x7fd25eae0844]
[0x40e97908]
Debug info from gdb:

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.

If I submit again it will likely pass the test.

@benaadams
Copy link
Contributor Author

hmm uv_async_send would be loop disposable; maybe just needs a handle.Validate

@benaadams benaadams changed the title Handle loss Handle Invalid Nov 6, 2015
@benaadams
Copy link
Contributor Author

If I add this Assert in I get two asserts running the tests

public void async_send(UvAsyncHandle handle)
{
    // Can't Assert with .Validate as that checks threadId
    // and this function is to post to correct thread.
    Debug.Assert(!handle.IsInvalid, "Handle is invalid");
    Check(_uv_async_send(handle));
}

Checking to see if its tests that are wrong rather than a race condition

benaadams added a commit to benaadams/KestrelHttpServer that referenced this issue Nov 6, 2015
@benaadams
Copy link
Contributor Author

Seems to mostly happen when posting close to a closed socket

This was referenced Nov 8, 2015
@benaadams
Copy link
Contributor Author

Does happen on Windows occasionally also:

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Microsoft.AspNet.Server.Kestrel.Networking.Libuv.NativeMethods.uv_async_send(UvAsyncHandle handle)
at Microsoft.AspNet.Server.Kestrel.Networking.Libuv.async_send(UvAsyncHandle handle)
at Microsoft.AspNet.Server.Kestrel.Networking.UvAsyncHandle.Send()
at Microsoft.AspNet.Server.Kestrel.KestrelThread.Post[T](Action1 callback, T state) at Microsoft.AspNet.Server.Kestrel.Http.SocketOutput.ScheduleWrite() at Microsoft.AspNet.Server.Kestrel.Http.SocketOutput.Write(ArraySegment1 buffer, Action`3 callback, Object state, Boolean immediate, Boolean socketShutdownSend, Boolean socketDisconnect)
at Microsoft.AspNet.Server.Kestrel.Http.SocketOutput.End(ProduceEndType endType)
at Microsoft.AspNet.Server.Kestrel.Http.Connection.Microsoft.AspNet.Server.Kestrel.Http.IConnectionControl.End(ProduceEndType endType)
at Microsoft.AspNet.Server.Kestrel.Http.Frame.d__82.MoveNext()

benaadams added a commit to benaadams/KestrelHttpServer that referenced this issue Nov 14, 2015
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

1 participant