Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=78739 --- shadow/78739 2006-06-30 09:48:19.000000000 -0400 +++ shadow/78739.tmp.16786 2006-06-30 09:48:19.000000000 -0400 @@ -0,0 +1,336 @@ +Bug#: 78739 +Product: Mono: Runtime +Version: 1.1 +OS: All +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: JIT +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: leaking tls data + +Mono is leaking tls data when calling mini_cleanup. + +Here is a patch to fix it. + + + +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/io-layer/critical-sections.c mono- +patch_unity/mono/io-layer/critical-sections.c +--- mono/mono/io-layer/critical-sections.c 2005-04-12 19:21:43.000000000 +0200 ++++ mono-patch_unity/mono/io-layer/critical-sections.c 2006-06-12 +05:40:39.000000000 +0200 +@@ -40,6 +40,15 @@ + g_assert (ret == 0); + } + ++ ++void critical_section_attr_cleanup(void) ++{ ++ pthread_mutexattr_destroy(&attr); ++} ++ ++ ++int gCounter = 0; ++ + /** + * InitializeCriticalSection: + * @section: The critical section to initialise +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/io-layer/critical-sections.h mono- +patch_unity/mono/io-layer/critical-sections.h +--- mono/mono/io-layer/critical-sections.h 2005-06-09 19:45:32.000000000 +0200 ++++ mono-patch_unity/mono/io-layer/critical-sections.h 2006-06-12 +05:41:02.000000000 +0200 +@@ -25,6 +25,9 @@ + mono_mutex_t mutex; + }; + ++extern void critical_section_attr_cleanup(void); ++ ++ + extern void InitializeCriticalSection(WapiCriticalSection *section); + extern gboolean InitializeCriticalSectionAndSpinCount(WapiCriticalSection *section, guint32 +spincount); + extern void DeleteCriticalSection(WapiCriticalSection *section); +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/io-layer/error.c mono-patch_unity/ +mono/io-layer/error.c +--- mono/mono/io-layer/error.c 2005-10-11 15:21:43.000000000 +0200 ++++ mono-patch_unity/mono/io-layer/error.c 2006-06-12 05:41:11.000000000 +0200 +@@ -46,6 +46,11 @@ + return(err); + } + ++void clenup_iolayer_error (void) ++{ ++ pthread_key_delete(error_key); ++} ++ + /** + * SetLastError: + * @code: The error code. +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/io-layer/error.h mono- +patch_unity/mono/io-layer/error.h +--- mono/mono/io-layer/error.h 2004-12-11 01:05:11.000000000 +0100 ++++ mono-patch_unity/mono/io-layer/error.h 2006-06-12 05:41:21.000000000 +0200 +@@ -1801,6 +1801,7 @@ + void SetLastError (guint32 code); + guint32 errno_to_WSA (guint32 code, const char *function_name); + gint _wapi_get_win32_file_error (gint err); ++void clenup_iolayer_error (void); + + G_END_DECLS + +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/io-layer/handles.c mono- +patch_unity/mono/io-layer/handles.c +--- mono/mono/io-layer/handles.c 2006-05-24 23:34:06.000000000 +0200 ++++ mono-patch_unity/mono/io-layer/handles.c 2006-06-12 05:41:26.000000000 +0200 +@@ -167,6 +167,9 @@ + } + + _wapi_shm_semaphores_remove (); ++ ++ mono_mutex_destroy(&_wapi_global_signal_mutex); ++ pthread_cond_destroy(&_wapi_global_signal_cond); + } + + static mono_once_t shared_init_once = MONO_ONCE_INIT; +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/io-layer/threads.c mono- +patch_unity/mono/io-layer/threads.c +--- mono/mono/io-layer/threads.c 2006-05-24 23:34:06.000000000 +0200 ++++ mono-patch_unity/mono/io-layer/threads.c 2006-06-12 05:41:54.000000000 +0200 +@@ -201,6 +201,12 @@ + g_assert (thr_ret == 0); + } + ++void thread_hash_cleanup(void) ++{ ++ pthread_key_delete(thread_attached_key); ++ pthread_key_delete(thread_hash_key); ++} ++ + static void _wapi_thread_suspend (struct _WapiHandle_thread *thread) + { + g_assert (thread->owner_pid == _wapi_getpid ()); +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/io-layer/threads.h mono- +patch_unity/mono/io-layer/threads.h +--- mono/mono/io-layer/threads.h 2006-05-24 23:34:06.000000000 +0200 ++++ mono-patch_unity/mono/io-layer/threads.h 2006-06-12 05:42:04.000000000 +0200 +@@ -65,5 +65,7 @@ + */ + extern void _wapi_thread_signal_self (guint32 exitstatus); + ++extern void thread_hash_cleanup(void); ++ + G_END_DECLS + #endif /* _WAPI_THREADS_H_ */ +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/appdomain.c mono- +patch_unity/mono/metadata/appdomain.c +--- mono/mono/metadata/appdomain.c 2006-06-06 15:29:04.000000000 +0200 ++++ mono-patch_unity/mono/metadata/appdomain.c 2006-06-12 05:42:32.000000000 ++0200 +@@ -28,6 +28,7 @@ + #include <mono/metadata/marshal.h> + #include <mono/metadata/monitor.h> + #include <mono/metadata/threadpool.h> ++#include <mono/metadata/mono-debug.h> + #include <mono/utils/mono-uri.h> + #include <mono/utils/mono-logger.h> + +@@ -206,6 +207,12 @@ + mono_network_cleanup (); + + mono_marshal_cleanup (); ++ ++ mono_type_initialization_cleanup (); ++ ++ mono_thread_pool_global_cleanup(); ++ ++ mono_monitor_cleanup (); + } + + static MonoDomainFunc quit_function = NULL; +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/domain.c mono- +patch_unity/mono/metadata/domain.c +--- mono/mono/metadata/domain.c 2006-06-06 15:29:04.000000000 +0200 ++++ mono-patch_unity/mono/metadata/domain.c 2006-06-12 05:43:19.000000000 +0200 +@@ -879,6 +881,10 @@ + mono_images_cleanup (); + mono_raw_buffer_cleanup (); + mono_metadata_cleanup (); ++ ++ TlsFree(appdomain_thread_id); ++ DeleteCriticalSection (&appdomains_mutex); ++ + } + + /** +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/gc.c mono-patch_unity/ +mono/metadata/gc.c +--- mono/mono/metadata/gc.c 2006-05-23 12:39:48.000000000 +0200 ++++ mono-patch_unity/mono/metadata/gc.c 2006-06-12 05:43:36.000000000 +0200 +@@ -843,6 +844,7 @@ + /* MS seems to wait for about 2 seconds */ + if (WaitForSingleObjectEx (shutdown_event, 2000, FALSE) == WAIT_TIMEOUT) { + mono_thread_stop (gc_thread); ++ mono_thread_detach(gc_thread); + } + } + gc_thread = NULL; +@@ -852,6 +854,10 @@ + } + + #endif ++ ++ DeleteCriticalSection (&handle_section); ++ DeleteCriticalSection (&allocator_section); ++ DeleteCriticalSection (&finalizer_mutex); + } + + #else +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/monitor.c mono- +patch_unity/mono/metadata/monitor.c +--- mono/mono/metadata/monitor.c 2006-03-16 17:18:43.000000000 +0100 ++++ mono-patch_unity/mono/metadata/monitor.c 2006-06-12 05:43:45.000000000 +0200 +@@ -85,6 +85,12 @@ + InitializeCriticalSection (&monitor_mutex); + } + ++void ++mono_monitor_cleanup (void) ++{ ++ DeleteCriticalSection (&monitor_mutex); ++} ++ + /* LOCKING: this is called with monitor_mutex held */ + static void + mon_finalize (MonoThreadsSync *mon) +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/monitor.h mono- +patch_unity/mono/metadata/monitor.h +--- mono/mono/metadata/monitor.h 2005-06-09 19:45:32.000000000 +0200 ++++ mono-patch_unity/mono/metadata/monitor.h 2006-06-12 05:43:48.000000000 +0200 +@@ -16,6 +16,7 @@ + G_BEGIN_DECLS + + void mono_monitor_init (void); ++void mono_monitor_cleanup (void); + + extern gboolean ves_icall_System_Threading_Monitor_Monitor_try_enter(MonoObject *obj, +guint32 ms); + extern void ves_icall_System_Threading_Monitor_Monitor_exit(MonoObject *obj); +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/object.c mono- +patch_unity/mono/metadata/object.c +--- mono/mono/metadata/object.c 2006-05-31 19:16:47.000000000 +0200 ++++ mono-patch_unity/mono/metadata/object.c 2006-06-12 05:43:55.000000000 +0200 +@@ -173,6 +173,15 @@ + InitializeCriticalSection (&ldstr_section); + } + ++void ++mono_type_initialization_cleanup (void) ++{ ++ DeleteCriticalSection (&type_initialization_section); ++ DeleteCriticalSection (&ldstr_section); ++} ++ ++ ++ + /* + * mono_runtime_class_init: + * @vtable: vtable that needs to be initialized +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/rawbuffer.h mono- +patch_unity/mono/metadata/rawbuffer.h +--- mono/mono/metadata/rawbuffer.h 2006-05-04 20:05:59.000000000 +0200 ++++ mono-patch_unity/mono/metadata/rawbuffer.h 2006-06-12 05:31:15.000000000 ++0200 +@@ -13,4 +13,6 @@ + void mono_raw_buffer_handle_pagefault (void *ptr); + guint32 mono_raw_buffer_get_n_pagefaults (void); + ++void *mono_raw_buffer_load_malloc (int fd, int is_writable, guint32 base, size_t size); ++ + #endif /* __MONO_RAWBUFFER_H__ */ +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/threadpool.c mono- +patch_unity/mono/metadata/threadpool.c +--- mono/mono/metadata/threadpool.c 2006-06-01 20:57:18.000000000 +0200 ++++ mono-patch_unity/mono/metadata/threadpool.c 2006-06-12 05:43:59.000000000 ++0200 +@@ -976,6 +976,13 @@ + g_assert (async_call_klass); + } + ++void mono_thread_pool_global_cleanup () ++{ ++ DeleteCriticalSection (&socket_io_data.io_lock); ++ DeleteCriticalSection (&ares_lock); ++} ++ ++ + MonoAsyncResult * + mono_thread_pool_add (MonoObject *target, MonoMethodMessage *msg, MonoDelegate +*async_callback, + MonoObject *state) +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/threadpool.h mono- +patch_unity/mono/metadata/threadpool.h +--- mono/mono/metadata/threadpool.h 2005-04-12 16:18:13.000000000 +0200 ++++ mono-patch_unity/mono/metadata/threadpool.h 2006-06-12 05:44:05.000000000 ++0200 +@@ -6,6 +6,7 @@ + + /* No managed code here */ + void mono_thread_pool_init (void); ++void mono_thread_pool_global_cleanup (void); + + MonoAsyncResult * + mono_thread_pool_add (MonoObject *target, MonoMethodMessage *msg, +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/metadata/threads.c mono- +patch_unity/mono/metadata/threads.c +--- mono/mono/metadata/threads.c 2006-05-25 18:12:30.000000000 +0200 ++++ mono-patch_unity/mono/metadata/threads.c 2006-06-12 05:44:11.000000000 +0200 +@@ -1814,6 +1814,8 @@ + DeleteCriticalSection (&contexts_mutex); + CloseHandle (background_change_event); + #endif ++ ++ TlsFree(current_object_key); + } + + void +diff -Naur --exclude .DS_Store --exclude '*.rej' mono/mono/mini/mini.c mono-patch_unity/ +mono/mini/mini.c +--- mono/mono/mini/mini.c 2006-06-08 22:49:05.000000000 +0200 ++++ mono-patch_unity/mono/mini/mini.c 2006-06-12 05:44:36.000000000 +0200 +@@ -11122,6 +11181,7 @@ + /* This accesses metadata so needs to be called before runtime shutdown */ + print_jit_stats (); + ++ + mono_runtime_cleanup (domain); + + mono_profiler_shutdown (); +@@ -11147,6 +11207,19 @@ + mono_trace_cleanup (); + + mono_counters_dump (-1, stdout); ++ ++ thread_hash_cleanup(); ++ clenup_iolayer_error(); ++ ++ TlsFree(mono_jit_tls_id); ++ ++ DeleteCriticalSection (&jit_mutex); ++ ++ critical_section_attr_cleanup(); ++ ++ mono_thread_pool_cleanup(); ++ ++ DeleteCriticalSection (&mono_delegate_section); + } + + void _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
