Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonojenkins <jo.shields+jenkins@xamarin.com>2020-10-22 22:19:40 +0300
committerGitHub <noreply@github.com>2020-10-22 22:19:40 +0300
commit93a7fe77e8e586ccc742b421113dbd0ac6e89bc7 (patch)
tree68f550c84074bcf4ffbe3334e4b45faeffbe065a
parent3db5b3584135cf636b95d4b3aa56be522dee2257 (diff)
Ensure special static slots respect alignment. (#20506)
Without proper alignment, this may lead to reference types being stored at non-pointer aligned offsets. Among other issues this may lead to the GC not scanning those pointers properly. Co-authored-by: Jonathan Chambers <joncham@gmail.com>
-rw-r--r--mono/metadata/threads.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c
index 147dacf05d5..5354a51b9e7 100644
--- a/mono/metadata/threads.c
+++ b/mono/metadata/threads.c
@@ -125,6 +125,7 @@ struct _StaticDataFreeList {
StaticDataFreeList *next;
guint32 offset;
guint32 size;
+ gint32 align;
};
typedef struct {
@@ -4744,12 +4745,12 @@ alloc_context_static_data_helper (gpointer key, gpointer value, gpointer user)
}
static StaticDataFreeList*
-search_slot_in_freelist (StaticDataInfo *static_data, guint32 size, guint32 align)
+search_slot_in_freelist (StaticDataInfo *static_data, guint32 size, gint32 align)
{
StaticDataFreeList* prev = NULL;
StaticDataFreeList* tmp = static_data->freelist;
while (tmp) {
- if (tmp->size == size) {
+ if (tmp->size == size && tmp->align == align) {
if (prev)
prev->next = tmp->next;
else
@@ -4907,7 +4908,7 @@ free_context_static_data_helper (gpointer key, gpointer value, gpointer user)
}
static void
-do_free_special_slot (guint32 offset, guint32 size)
+do_free_special_slot (guint32 offset, guint32 size, gint32 align)
{
guint32 static_type = ACCESS_SPECIAL_STATIC_OFFSET (offset, type);
MonoBitSet **sets;
@@ -4940,6 +4941,7 @@ do_free_special_slot (guint32 offset, guint32 size)
item->offset = offset;
item->size = size;
+ item->align = align;
item->next = info->freelist;
info->freelist = item;
@@ -4954,7 +4956,7 @@ do_free_special (gpointer key, gpointer value, gpointer data)
gint32 align;
guint32 size;
size = mono_type_size (field->type, &align);
- do_free_special_slot (offset, size);
+ do_free_special_slot (offset, size, align);
}
void