On amd64 MONO_SIZEOF_TYPE is 12 and sizeof(MonoType) is 16. This leads to memory corruption
if one uses sizeof instead of the specific size.
This is one of those oddball behaviors of the runtime that makes easy things very hard. :(
MonoMethodSignature *ret;
sigsize = sig_header_size = MONO_SIZEOF_METHOD_SIGNATURE + sig->param_count * sizeof (MonoType *) + padding;
if (sig->ret)
- sigsize += sizeof (MonoType);
+ sigsize += MONO_SIZEOF_TYPE;
if (image) {
ret = mono_image_alloc (image, sigsize);
// Danger! Do not alter padding use without changing the dup_add_this below
intptr_t end_of_header = (intptr_t)( (char*)(ret) + sig_header_size);
ret->ret = (MonoType *)end_of_header;
- *ret->ret = *sig->ret;
+ memcpy (ret->ret, sig->ret, MONO_SIZEOF_TYPE);
}
return ret;