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=77521 --- shadow/77521 2006-02-09 19:59:41.000000000 -0500 +++ shadow/77521.tmp.6853 2006-02-09 19:59:41.000000000 -0500 @@ -0,0 +1,85 @@ +Bug#: 77521 +Product: Mono: Runtime +Version: 1.1 +OS: GNU/Linux [Other] +OS Details: Linux 2.6.14 (Debian Stable, amd64) Linux 2.6.9 (CentOS 4, ia32) +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: misc +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: mono_thread_attach/mono_thread_detach leak memory on Linux + +Please fill in this template when reporting a bug, unless you know what you are doing. +Description of Problem: + +Usage of mono_thread_attach/mono_thread_detach seem to cause memory leakage on amd64 +Linux and ia32 Linux. + +Steps to reproduce the problem: +1. Run the ever-so-popular racy.c sample code against Mono from svn (I used r56740): + +#include <pthread.h> +#include <mono/jit/jit.h> +#include <mono/metadata/metadata.h> +#include <mono/metadata/debug-helpers.h> +#include <mono/metadata/object.h> +#include <mono/metadata/threads.h> +#include <mono/metadata/appdomain.h> + +#define CHUNK_THREADCOUNT 200 + +static void *thread_function(void *monoDomain) { + printf("Attaching thread...\n"); + MonoThread *monoThread = mono_thread_attach((MonoDomain *)monoDomain); + printf("Thread (%p) attached.\n", monoThread); + + //normally, some threaded stuff would happen here. + + printf("Detaching thread (%p)\n", monoThread); + mono_thread_detach(monoThread); + printf("Thread (%p) detached.\n", monoThread); +} + +int main(int argc, char *argv[]) { + + mono_set_defaults(0, mono_parse_default_optimizations(NULL)); + MonoDomain *monoDomain = mono_jit_init("racy"); + + while(TRUE) { + pthread_t threads[CHUNK_THREADCOUNT]; + int i; + + for(i = 0; i < CHUNK_THREADCOUNT; i++) + pthread_create(threads + i, NULL, thread_function, monoDomain); + + for(i = 0; i < CHUNK_THREADCOUNT; i++) + pthread_join(threads[i], NULL); + } + + return(0); +} + +2. Watch memory usage grow without bound. + +Actual Results: +Memory usage increases without bound. + +Expected Results: +Program should not leak memory. + +How often does this happen? +Always. + +Additional Information: + +This may have something to do with Dick's fix for Bug #77468. After updating to r56740, the +sample code leaks memory on ia32 and amd64 Linux. The leak seems to happen more slowly on +ia32. The sample code either does not leak on OS X or leaks so slowly, the segfault/deadlock +detailed in Bug #77470 appears before memory usage is noticeable. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
