Skip to content

Commit

Permalink
[threads] Check InternalThread.last just after checking corlib version
Browse files Browse the repository at this point in the history
  • Loading branch information
luhenry committed Sep 16, 2016
1 parent f11615a commit 1c9e34c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 8 additions & 2 deletions mono/metadata/appdomain.c
Expand Up @@ -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;
}

/**
Expand Down
3 changes: 0 additions & 3 deletions mono/metadata/threads.c
Expand Up @@ -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)
Expand Down

0 comments on commit 1c9e34c

Please sign in to comment.