Bug 317291 (MONO72970) - RACE: Environment.Exit and new threads
Summary: RACE: Environment.Exit and new threads
Status: RESOLVED MOVED
Alias: MONO72970
Product: Mono: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: unspecified
Hardware: Other Linux
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-24 17:30 UTC by Vadim Guzev
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:08:44 UTC


---- Reported by vguzev@yandex.ru 2005-02-24 10:30:43 MST ----

Description of Problem:
A lot of different errors are thrown when trying to exit application 
that's creating new threads... These types of errors depends of what 
these new threads are busy with.

Steps to reproduce the problem:
1. mcs test.cs
--8<----test.cs-----------------------------
using System;
using System.Threading;

public class test {
 public static void StartNewThread() {
  Thread t = new Thread( new ThreadStart( StartNewThread ) );
  t.Start();
  DateTime dt = DateTime.Now;
 }

 public static void Main( string[] args ) {
  Thread t = new Thread( new ThreadStart( StartNewThread ) );
  t.Start();
  Thread.Sleep( 1000 );
  Environment.Exit( 0 );
 }
}
--8<-----------------------------------------
2. mono test.exe

Actual Results:
I'm getting a lot of mistakes like this:
--8<-----------------------------------------
Unhandled Exception: System.ArgumentException: Key duplication when 
adding: 2005
in <0x001d7> System.Collections.Hashtable:PutImpl (object,object,bool)
in <0x00015> System.Collections.Hashtable:Add (object,object)
in <0x001f5> System.CurrentTimeZone:GetDaylightChanges (int)
in <0x0002b> System.TimeZone:IsDaylightSavingTime (System.DateTime)
in <0x0001b> System.CurrentTimeZone:GetUtcOffset (System.DateTime)
in <0x00064> System.DateTime:.ctor (bool,long)
in <0x0002e> System.DateTime:get_Now ()
in <0x0006d> test:StartNewThread ()
in <0x00041> (wrapper delegate-invoke) 
System.MulticastDelegate:invoke_void ()
--8<-----------------------------------------

Sometimes the application just hangs on...

What's interesting, if I replace the string 'DateTime dt = DateTime.Now;' 
with the following line:
IPAddress hostadd = Dns.Resolve( Dns.GetHostName() ).AddressList[0];
then I'm getting the following error:
--8<-----------------------------------------
[vadim@skif testexitwithnewthreads]$ mono test.exe

** ERROR **: : EnterCriticalSection failed: Invalid argument
aborting...
Aborted
--8<-----------------------------------------

Expected Results:
Should work OK with Mono, as it's working well on MS.Net.

How often does this happen? 
Always

Additional Information:
--8<-----------------------------------------
[vadim@skif testexitwithnewthreads]$ uname -a
Linux skif 2.4.25 #2 SMP Fri Apr 23 14:03:00 MSD 2004 i686 athlon i386 
GNU/Linux
[vadim@skif testexitwithnewthreads]$ mono --version
Mono JIT compiler version 1.1.4, (C) 2002-2004 Novell, Inc and 
Contributors. www.go-mono.com
        TLS:           __thread
        GC:            Included Boehm (with typed GC)
        SIGSEGV      : normal
        Globalization: none
--8<-----------------------------------------


Best regards,
Vadim B. Guzev
http://u.pereslavl.ru/~vadim/MCSharp/



---- Additional Comments From vguzev@yandex.ru 2005-02-24 10:41:39 MST ----

And if I replace the line 'DateTime dt = DateTime.Now;' with
'string command = Environment.CommandLine;' then I'm getting the 
following errors:
--8<-------------------------------------------
[vadim@skif testexitwithnewthreads]$ mono test.exe

** ERROR **: file critical-sections.c: line 172 
(LeaveCriticalSection): assertion failed: (ret == 0)
aborting...
Aborted
[vadim@skif testexitwithnewthreads]$ mono test.exe

(test.exe:1218): GLib-CRITICAL **: file ghash.c: line 225 
(g_hash_table_lookup): assertion `hash_table != NULL' failed
--8<-------------------------------------------

This errors are the subject for bug 
https://bugzilla.novell.com/show_bug.cgi?id=MONO72637


Best regards,
Vadim B. Guzev
http://u.pereslavl.ru/~vadim/MCSharp/



---- Additional Comments From vargaz@gmail.com 2005-02-24 12:07:54 MST ----



*** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO71274 ***


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Linux skif 2.4.25 #2 SMP Fri Apr 23 14:03:00 MSD 2004 i686 athlon i386 GNU/Linux</cf_op_sys_details>
This bug was marked DUPLICATE in the database it was moved from.
    Changing resolution to "MOVED"