[w2file] Fix shutdown assert in checked mode
authorAleksey Kliger <aleksey@xamarin.com>
Wed, 15 Feb 2017 20:58:21 +0000 (15:58 -0500)
committerAleksey Kliger (λgeek) <akliger@gmail.com>
Thu, 16 Feb 2017 18:45:00 +0000 (13:45 -0500)
console_close triggered a MONO_REQ_GC_SAFE_MODE assert in checked mode on
because the console handles were unref'd which caused them to close.

Until w32handle is coop-aware, just transition to GC unsafe mode (a noop if
it's already in unsafe) in these callbacks.

mono/metadata/w32file-unix.c

index 09eb6b1bc878f61f0eb79d306efad6894f12f9b2..9666cb67d9d0cbda59c938c69f4c77e864c375ea 100644 (file)
@@ -1099,7 +1099,7 @@ static void _wapi_set_last_path_error_from_errno (const gchar *dir,
  */
 static void file_close (gpointer handle, gpointer data)
 {
-       MONO_REQ_GC_SAFE_MODE; /* FIXME: after mono_w32handle_close is coop-aware, change this to UNSAFE_MODE and switch to SAFE around close() below */
+       /* FIXME: after mono_w32handle_close is coop-aware, change this to MONO_REQ_GC_UNSAFE_MODE and leave just the switch to SAFE around close() below */
        MONO_ENTER_GC_UNSAFE;
        MonoW32HandleFile *file_handle = (MonoW32HandleFile *)data;
        gint fd = file_handle->fd;
@@ -1839,7 +1839,7 @@ static gboolean file_setfiletime(gpointer handle,
 
 static void console_close (gpointer handle, gpointer data)
 {
-       MONO_REQ_GC_SAFE_MODE; /* FIXME: after mono_w32handle_close is coop-aware, change this to UNSAFE_MODE and switch to SAFE around close() below */
+       /* FIXME: after mono_w32handle_close is coop-aware, change this to MONO_REQ_GC_UNSAFE_MODE and leave just the switch to SAFE around close() below */
        MONO_ENTER_GC_UNSAFE;
        MonoW32HandleFile *console_handle = (MonoW32HandleFile *)data;
        gint fd = console_handle->fd;
@@ -1998,7 +1998,7 @@ static gsize find_typesize (void)
 
 static void pipe_close (gpointer handle, gpointer data)
 {
-       MONO_REQ_GC_SAFE_MODE; /* FIXME: after mono_w32handle_close is coop-aware, change this to UNSAFE_MODE and switch to SAFE around close() below */
+       /* FIXME: after mono_w32handle_close is coop-aware, change this to MONO_REQ_GC_UNSAFE_MODE and leave just the switch to SAFE around close() below */
        MONO_ENTER_GC_UNSAFE;
        MonoW32HandleFile *pipe_handle = (MonoW32HandleFile*)data;
        gint fd = pipe_handle->fd;