提交 32f3f62d 编写于 作者: J Jonathan Chambers 提交者: Dharmendra Tomar

Ensure special static slots respect alignment (case 1266322)

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.
上级 325712c8
......@@ -113,6 +113,7 @@ struct _StaticDataFreeList {
StaticDataFreeList *next;
guint32 offset;
guint32 size;
gint32 align;
};
typedef struct {
......@@ -4271,12 +4272,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
......@@ -4434,7 +4435,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;
......@@ -4467,6 +4468,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;
......@@ -4481,7 +4483,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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册