Bug 56722 - Attaching to a thread at runtime leaks
Summary: Attaching to a thread at runtime leaks
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: 5.0 (2017-02)
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: 2018-01-05 14:35 UTC (History)
4 users (show)

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


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

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
Comment 4 Ludovic Henry 2018-01-05 14:35:35 UTC
I cannot reproduce with 5.10.0.18 (2017-12/dcaf47f5187), please reopen if you still can. Thank you.