[PATCH] mscoree: Call mono_thread_manage in GC Unsafe mode.

Vincent Povirk (they/them) vincent at codeweavers.com
Thu Oct 24 18:03:58 CDT 2019


Please ignore for now, it looks like this may be getting fixed on the Mono side.

On Thu, Oct 24, 2019 at 4:01 PM Vincent Povirk <vincent at codeweavers.com> wrote:
>
> The mono_thread_manage API expects to be called in GC Unsafe mode.
>
> This has been the case for a while, but for some reason it only
> caused problems in the Mono merge I'm working on now.
>
> We don't need a matching exit call because we're shutting down
> the runtime anyway, and we can't change GC modes after the runtime
> shuts down.
>
> Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
> ---
>  dlls/mscoree/corruntimehost.c  | 2 ++
>  dlls/mscoree/metahost.c        | 2 ++
>  dlls/mscoree/mscoree_private.h | 1 +
>  3 files changed, 5 insertions(+)
>
> diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c
> index e932a7f58be..b72af709c03 100644
> --- a/dlls/mscoree/corruntimehost.c
> +++ b/dlls/mscoree/corruntimehost.c
> @@ -1544,6 +1544,8 @@ __int32 WINAPI _CorExeMain(void)
>
>      if (domain)
>      {
> +        int dummy;
> +        mono_threads_enter_gc_unsafe_region(&dummy);
>          mono_thread_manage();
>          mono_runtime_quit();
>      }
> diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c
> index 18232a45686..575d6ce1d39 100644
> --- a/dlls/mscoree/metahost.c
> +++ b/dlls/mscoree/metahost.c
> @@ -124,6 +124,7 @@ MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str);
>  static char* (CDECL *mono_stringify_assembly_name)(MonoAssemblyName *aname);
>  MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain);
>  void (CDECL *mono_thread_manage)(void);
> +void (CDECL *mono_threads_enter_gc_unsafe_region)(void *stackdata);
>  void (CDECL *mono_trace_set_print_handler)(MonoPrintCallback callback);
>  void (CDECL *mono_trace_set_printerr_handler)(MonoPrintCallback callback);
>
> @@ -224,6 +225,7 @@ static HRESULT load_mono(LPCWSTR mono_path)
>          LOAD_MONO_FUNCTION(mono_string_new);
>          LOAD_MONO_FUNCTION(mono_thread_attach);
>          LOAD_MONO_FUNCTION(mono_thread_manage);
> +        LOAD_MONO_FUNCTION(mono_threads_enter_gc_unsafe_region);
>
>  #undef LOAD_MONO_FUNCTION
>
> diff --git a/dlls/mscoree/mscoree_private.h b/dlls/mscoree/mscoree_private.h
> index 2b9c1dd35e5..250bd24ad10 100644
> --- a/dlls/mscoree/mscoree_private.h
> +++ b/dlls/mscoree/mscoree_private.h
> @@ -177,6 +177,7 @@ extern void (CDECL *mono_runtime_quit)(void) DECLSPEC_HIDDEN;
>  extern MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str) DECLSPEC_HIDDEN;
>  extern MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain) DECLSPEC_HIDDEN;
>  extern void (CDECL *mono_thread_manage)(void) DECLSPEC_HIDDEN;
> +extern void (CDECL *mono_threads_enter_gc_unsafe_region)(void *stackdata) DECLSPEC_HIDDEN;
>  extern void (CDECL *mono_trace_set_print_handler)(MonoPrintCallback callback) DECLSPEC_HIDDEN;
>  extern void (CDECL *mono_trace_set_printerr_handler)(MonoPrintCallback callback) DECLSPEC_HIDDEN;
>
> --
> 2.17.1
>
>



More information about the wine-devel mailing list