Bug 56722 - Attaching to a thread at runtime leaks
Summary: Attaching to a thread at runtime leaks
Status: CONFIRMED
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: 5.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-05-22 13:36 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2017-10-09 23:18 UTC (History)
4 users (show)

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


Attachments
native-thread-leak.zip (1.24 KB, application/zip)
2017-05-22 13:36 UTC, Rolf Bjarne Kvinge [MSFT]
Details

Description Rolf Bjarne Kvinge [MSFT] 2017-05-22 13:36:20 UTC
Created attachment 22351 [details]
native-thread-leak.zip

Repro:
* Unzip attached test case
* Run make
* Observe the process in the Activity Monitor (on mac), and see how memory usage grows.
Comment 2 Zoltan Varga 2017-05-24 17:02:04 UTC
Looks like thread_handle_destroy () is not called among others.
Comment 3 Ludovic Henry 2017-10-09 23:18:09 UTC
I can reproduce with Mono 5.8.0.2 (2017-10/a3943e28cf8)

Following are some of the stacktraces in decreasing order of total amount of memory leaked:

>  0 libsystem_malloc.dylib malloc_zone_calloc
>  1 libsystem_malloc.dylib calloc
>  2 mono-sgen64 monoeg_g_calloc /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:114
>  3 mono-sgen64 monoeg_malloc0 /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:121
>  4 mono-sgen64 setup_jit_tls_data /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/mini/mini-runtime.c:914
>  5 mono-sgen64 mono_thread_attach_cb /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/mini/mini-runtime.c:976
>  6 mono-sgen64 mono_thread_attach_full /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/metadata/threads.c:1133
>  7 mono-sgen64 mono_jit_thread_attach /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/mini/mini-runtime.c:856
>  8  0x102be13fc
>  9 libtest.dylib call
> 10 libsystem_pthread.dylib _pthread_body
> 11 libsystem_pthread.dylib _pthread_start
> 12 libsystem_pthread.dylib thread_start

>  0 libsystem_malloc.dylib malloc_zone_calloc
>  1 libsystem_malloc.dylib calloc
>  2 mono-sgen64 monoeg_g_calloc /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:114
>  3 mono-sgen64 monoeg_malloc0 /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:121
>  4 mono-sgen64 ref_stack_new /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/metadata/threads.c:3779
>  5 mono-sgen64 mono_thread_push_appdomain_ref /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/metadata/threads.c:3849
>  6 mono-sgen64 mono_thread_attach_internal /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/metadata/threads.c:677
>  7 mono-sgen64 mono_thread_attach_full /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/metadata/threads.c:1116
>  8 mono-sgen64 mono_jit_thread_attach /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/mini/mini-runtime.c:856
>  9  0x102be13fc
> 10 libtest.dylib call
> 11 libsystem_pthread.dylib _pthread_body
> 12 libsystem_pthread.dylib _pthread_start
> 13 libsystem_pthread.dylib thread_start

>  0 libsystem_malloc.dylib malloc_zone_calloc
>  1 libsystem_malloc.dylib calloc
>  2 mono-sgen64 monoeg_g_calloc /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:114
>  3 mono-sgen64 monoeg_malloc0 /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:121
>  4 mono-sgen64 create_internal_thread_object /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/metadata/threads.c:567
>  5 mono-sgen64 mono_thread_attach_full /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/metadata/threads.c:1112
>  6 mono-sgen64 mono_jit_thread_attach /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/mini/mini-runtime.c:856
>  7  0x102be13fc
>  8 libtest.dylib call
>  9 libsystem_pthread.dylib _pthread_body
> 10 libsystem_pthread.dylib _pthread_start
> 11 libsystem_pthread.dylib thread_start

>  0 libsystem_malloc.dylib malloc_zone_calloc
>  1 libsystem_malloc.dylib calloc
>  2 mono-sgen64 monoeg_g_calloc /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:114
>  3 mono-sgen64 monoeg_malloc0 /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:121
>  4 mono-sgen64 mono_thread_info_attach /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/utils/mono-threads.c:366
>  5 mono-sgen64 mono_thread_attach_full /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/metadata/threads.c:1107
>  6 mono-sgen64 mono_jit_thread_attach /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/mini/mini-runtime.c:856
>  7  0x102be13fc
>  8 libtest.dylib call
>  9 libsystem_pthread.dylib _pthread_body
> 10 libsystem_pthread.dylib _pthread_start
> 11 libsystem_pthread.dylib thread_start

>  0 libsystem_malloc.dylib malloc_zone_calloc
>  1 libsystem_malloc.dylib calloc
>  2 mono-sgen64 monoeg_g_calloc /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:114
>  3 mono-sgen64 monoeg_malloc0 /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gmem.c:121
>  4 mono-sgen64 monoeg_g_ptr_array_sized_new /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gptrarray.c:70
>  5 mono-sgen64 monoeg_g_ptr_array_new /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/eglib/src/gptrarray.c:64
>  6 mono-sgen64 mono_os_event_init /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/utils/os-event-unix.c:35
>  7 mono-sgen64 mono_thread_info_attach /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/utils/mono-threads.c:368
>  8 mono-sgen64 mono_thread_attach_full /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/metadata/threads.c:1107
>  9 mono-sgen64 mono_jit_thread_attach /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mono/mini/mini-runtime.c:856
> 10  0x102be13fc
> 11 libtest.dylib call
> 12 libsystem_pthread.dylib _pthread_body
> 13 libsystem_pthread.dylib _pthread_start
> 14 libsystem_pthread.dylib thread_start

Note You need to log in before you can comment on or make changes to this bug.