[Mono-dev] [PATCH] TcpChannel hang on Windows.

Kornél Pál kornelpal at gmail.com
Tue Dec 30 13:02:42 EST 2008


Hi,

This simple test case shows that background threads are killed even if 
they are executing managed code. The easiest way to kill the threads is 
to kill the process itself so I think that this is what MS.NET does but 
killing the threads one by one results in the same behavior.

Programs that would break on Mono because of this change are broken on 
MS.NET as well.

This is the MS.NET behavior that can be easily shown using simple test 
cases.

I know that you are aware of this and you have described this in your 
messages but this behavior cannot be worked around (unless you call 
ExitProcess) this has to be implemented in the runtime.

If Mono aims to be MS.NET compatible, and this is an important 
difference that should be addressed.

Also note that your workaround for Accept is not compatible with MS.NET 
because that makes Accept abortable that is not the case in MS.NET either.

Kornél

Bill Holmes wrote:
> Kornél,
> 
> I do agree that this is a general problem and not only an issue with
> accept.  Also I do know that the patch is a workaround, or as we like
> to say treading the symptom and not that cause.
> 
> I have spent much time trying to understand the shutdown behavior of
> MS.  From what I can gather I does appear that MS kills the thread or
> simply ignores it.  (So we agree on that as well.)
> 
> For Mono I would suggest that killing all background threads on
> shutdown.  (and only shutdown.)  Ignoring the thread and allowing it
> to live on allows a window of opportunity to attempt to interact with
> other Mono internal objects that have been destroyed.  Therefore
> killing the thread I believe is the better option.
> 
> Another reason I believe that MS simply kills the thread is a
> different sample I tried.  Consider a program that spawns a background
> thread.  That thread only PInvokes into a call that simply loops.
> (while (1);)  The program does exit with MS.Net.
> 
> I have discussed this on IRC with a few others and exiting the thread
> is an unpopular solution.  Killing a thread is about as accepted as
> using goto statements.  ;)
> 
> To be honest, even though I have spent 2 weeks looking at this I still
> do not feel comfortable that the Mono shutdown logic can handle
> killing threads.  Another way to put it I am afraid that changing the
> shutdown logic would cause currently working Mono apps to start
> bombing because I just do not understand the full picture.
> 
> -bill
> 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: BackgroundThread.cs
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20081230/e627580a/attachment.pl 


More information about the Mono-devel-list mailing list