[runtime] Fixed marshalling bug in `mono_marshal_get_native_func_wrapper`.
authorJoão Matos <joao@tritao.eu>
Fri, 6 Feb 2015 12:35:32 +0000 (12:35 +0000)
committerJoão Matos <joao@tritao.eu>
Fri, 6 Feb 2015 12:35:45 +0000 (12:35 +0000)
commita8390dcd63d466a12ddd1b159f110320b315031b
treea0f83e788fa89520c6b47263d0e9186836e909a4
parent6733010353a6024a2b437a6cd5c5c30ae6e99218
[runtime] Fixed marshalling bug in `mono_marshal_get_native_func_wrapper`.

It was caused by a mismatch of the `sig` and `csig` variables when looking the wrapper in the marshalling cache.

This was manifesting as the following crash in all Monodroid programs:

```
#0  mono_type_hash () at /Users/joao/Dev/droid/mono/mono/metadata/metadata.c:1390
#1  0x7512edf4 in mono_signature_hash () at /Users/joao/Dev/droid/mono/mono/metadata/metadata.c:4957
#2  0x75115d18 in signature_pointer_pair_hash () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#3  0x751dca10 in rehash () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#4  0x751dcbe0 in monoeg_g_hash_table_insert_replace () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#5  0x75119570 in mono_mb_create_and_cache_full () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#6  0x75127390 in mono_marshal_get_native_func_wrapper () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#7  0x75127780 in mono_ftnptr_to_delegate () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
```

Originally introduced in https://github.com/mono/mono/pull/1540.
mono/metadata/marshal.c