Permalink
Browse files

[threads] Check InternalThread.last just after checking corlib version

  • Loading branch information...
1 parent f11615a commit 1c9e34cce5e53ec5126d546a3014bc1493425219 @luhenry luhenry committed Sep 16, 2016
Showing with 8 additions and 5 deletions.
  1. +8 −2 mono/metadata/appdomain.c
  2. +0 −3 mono/metadata/threads.c
View
@@ -343,8 +343,14 @@ mono_check_corlib_version (void)
int version = mono_get_corlib_version ();
if (version != MONO_CORLIB_VERSION)
return g_strdup_printf ("expected corlib version %d, found %d.", MONO_CORLIB_VERSION, version);
- else
- return NULL;
+
+ /* Check that the managed and unmanaged layout of MonoInternalThread matches */
+ guint32 native_offset = (guint32) MONO_STRUCT_OFFSET (MonoInternalThread, last);
+ guint32 managed_offset = mono_field_get_offset (mono_class_get_field_from_name (mono_defaults.internal_thread_class, "last"));
+ if (native_offset != managed_offset)
+ return g_strdup_printf ("expected InternalThread.last field offset %u, found %u. See InternalThread.last comment", native_offset, managed_offset);
+
+ return NULL;
}
/**
View
@@ -2849,9 +2849,6 @@ void mono_thread_init (MonoThreadStartCB start_cb,
* anything up.
*/
GetCurrentProcess ();
-
- /* Check that the managed and unmanaged layout of MonoInternalThread matches */
- g_assert (MONO_STRUCT_OFFSET (MonoInternalThread, last) == mono_field_get_offset (mono_class_get_field_from_name (mono_defaults.internal_thread_class, "last")));
}
void mono_thread_cleanup (void)

0 comments on commit 1c9e34c

Please sign in to comment.