Bug 28430 - Cannot transition thread from RUNNING with FINISH_ASYNC_SUSPEND
Summary: Cannot transition thread from RUNNING with FINISH_ASYNC_SUSPEND
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-03-25 19:36 UTC by pr0vieh
Modified: 2015-05-11 14:59 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

Full Stacktrace (55.21 KB, application/octet-stream)
2015-03-25 19:36 UTC, pr0vieh
Testcase (941 bytes, application/octet-stream)
2015-04-19 12:44 UTC, Kari Takanen
Better(?) testcase (40 bytes, text/plain)
2015-04-24 10:28 UTC, Kari Takanen

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description pr0vieh 2015-03-25 19:36:19 UTC
Created attachment 10506 [details]
Full Stacktrace

Cannot transition thread 0xf43011b8 from RUNNING with FINISH_ASYNC_SUSPEND

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Net.Sockets.Socket.Connect_internal (intptr,System.Net.SocketAddress,int&) <0xffffffff>
  at System.Net.Sockets.Socket.Connect_internal (System.Net.Sockets.SafeSocketHandle,System.Net.SocketAddress,int&) <0x00033>
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint) <0x000e7>
  at System.Net.WebConnection.Connect (System.Net.HttpWebRequest) <0x0042f>
  at System.Net.WebConnection.InitConnection (object) <0x0021b>
  at System.Net.WebConnection.<WebConnection>m__0 (object) <0x00017>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        mono(mono_handle_native_sigsegv+0xe0) [0x8114960]
        /lib/i386-linux-gnu/libc.so.6(gsignal+0x47) [0xf750d607]
        /lib/i386-linux-gnu/libc.so.6(abort+0x143) [0xf750ed83]
        mono() [0x8295a1f]
        mono(monoeg_g_logv+0x5d) [0x8295bcd]
        mono(monoeg_g_log+0x25) [0x8295c35]
        mono(mono_threads_transition_finish_async_suspend+0x46) [0x828e536]
        mono() [0x828eba9]
        /lib/i386-linux-gnu/libc.so.6(__poll+0x4b) [0xf75bf4db]
        mono(mono_poll+0x20) [0x8288ee0]
        mono(_wapi_connect+0xf1) [0x8275051]
        mono(ves_icall_System_Net_Sockets_Socket_Connect_internal+0x5b) [0x81dd74b]
        mono() [0x80912a8]
Comment 1 pr0vieh 2015-03-25 19:41:24 UTC
i forget 
Mono JIT compiler version 4.1.0 (master/a081090 Mi 25. Mär 23:19:27 CET 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen
Comment 2 pr0vieh 2015-03-27 11:14:25 UTC
this is happens very often...
my tool is crashing in less then 10 min under usage :/
Comment 3 Alexander Kyte 2015-03-30 14:38:34 UTC
If you could upload a code sample which triggers this bug, it would make reproducing and fixing it much easier.
Comment 5 Rodrigo Kumpera 2015-04-02 11:27:31 UTC
Unfortunately the backtrace in this case is not enough to have something to work with.

Please provide a test case that allow us to reproduce this behavior.
Comment 6 Kari Takanen 2015-04-19 12:44:50 UTC
Created attachment 10813 [details]
Comment 7 Kari Takanen 2015-04-19 12:45:26 UTC
Here's a test case.
Comment 8 Kari Takanen 2015-04-24 10:28:00 UTC
Created attachment 10892 [details]
Better(?) testcase
Comment 9 Kari Takanen 2015-04-24 10:31:36 UTC
Looks like there needs to be some CPU load for this to occur, so here's another testcase. Please let me know if it doesn't work and I'll provide access to a test box where it can be reproduced.
Comment 10 Kari Takanen 2015-04-24 11:44:29 UTC
Also seems to help if you run several instances at the same time, for example in while loop in screen.
Comment 11 Rodrigo Kumpera 2015-04-27 12:28:44 UTC
Hi Kari,

Thanks for the updated test case, I'll give it a try this week and report back results.
Comment 12 Alexander Köplinger 2015-05-10 10:37:03 UTC
I see the same issue when running the System testsuite on Linux (locally, on my CI and on Mono Jenkins). Although with a slightly different stacktrace:

> Cannot transition thread 0x2b9f780008e0 from RUNNING with FINISH_ASYNC_SUSPEND
> Stacktrace:
>   at <unknown> <0xffffffff>
>   at (wrapper managed-to-native) System.Net.Sockets.Socket.Accept_internal (intptr,int&,bool) <IL 0x0000f, 0xffffffff>
>   at System.Net.Sockets.Socket.Accept_internal (System.Net.Sockets.SafeSocketHandle,int&,bool) [0x00006] in /home/alexander/dev/mono/mcs/class/System/System.Net.Sockets/Socket.cs:1066
>   at System.Net.Sockets.Socket.Accept () [0x00008] in /home/alexander/dev/mono/mcs/class/System/System.Net.Sockets/Socket.cs:893
>   at System.Net.Sockets.TcpListener.AcceptSocket () [0x00016] in /home/alexander/dev/mono/mcs/class/System/System.Net.Sockets/TcpListener.cs:184
>   at MonoTests.System.Net.SocketResponder.Listen () [0x00007] in /home/alexander/dev/mono/mcs/class/System/Test/System.Net/SocketResponder.cs:111
>   at System.Threading.Thread.StartInternal () [0x00016] in /home/alexander/dev/mono/mcs/class/corlib/System.Threading/Thread.cs:694
>   at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <IL 0x00056, 0xffffffff>

It reproduces 100% of the time (though sometimes the testsuite just deadlocks).

With the "Better(?) testcase" from Kari I can also repro the issue in a few seconds on a Mono built today.

Digging through my CI logs, this is happening since quite some time. The first time it happened with commit 0468321ad188 (but that commit only changes something for android, so it was likely introduced earlier). It then happens very rarely, up until https://github.com/mono/mono/pull/1691 was merged. From then on it happens 100% of the time.

Comment 13 Rodrigo Kumpera 2015-05-11 14:59:28 UTC
A PR to fix the issue was just merged: