Fix SafeHandle marshalling in ref/in/out parameters (mono/mono#17330)
authorFilip Navara <navara@emclient.com>
Wed, 16 Oct 2019 05:43:42 +0000 (07:43 +0200)
committerZoltan Varga <vargaz@gmail.com>
Wed, 16 Oct 2019 05:43:42 +0000 (01:43 -0400)
commit6ed0b492c18b90bcb0ea5d2f30ddd80c61828139
treea705a9ab9dc9a1570c97376bd673a2a92c469659
parent5b2d0a3e4fb4ac1b34efeb2213d4d66418148c83
Fix SafeHandle marshalling in ref/in/out parameters (mono/mono#17330)

* Fix SafeHandle marshalling in ref/in/out parameters

* Reorder code to make it exception safe, update comments

* Revert the code reordering because it breaks the invariant that new handle returned from native code should always create new SafeHandle on the managed side

* Fix test_0_safehandle_ref test. The test was expecting incorrect behavior, verified on .NET Core 3 and .NET Framework 4.8.

* Address PR feedback

* Fix cut & paste error

* Fix build

* Really fix the test_0_safehandle_ref tests

* Add more tests for SafeHandle marshalling

* Add exclusion for broken CoreFX test

Commit migrated from https://github.com/mono/mono/commit/0c02bb1207af75c176c369e411d9f4407e21030d
src/mono/mono/metadata/marshal-ilgen.c
src/mono/mono/tests/libtest.c
src/mono/mono/tests/safehandle.2.cs
src/mono/netcore/CoreFX.issues.rsp