[marshal] allocate dummy string always in root domain
authorBernhard Urban <bernhard.urban@xamarin.com>
Wed, 7 Jun 2017 16:28:32 +0000 (18:28 +0200)
committerBernhard Urban <bernhard.urban@xamarin.com>
Fri, 9 Jun 2017 10:49:59 +0000 (12:49 +0200)
otherwise it can happen that the dummy string is allocated in a
different domain, and when it's onloaded the GC root points to an
invalid object.

mono/metadata/marshal.c

index 4b49d2e9a9afe6f7223348456a68bd2544af108b..968c34ec79c99490429e0578873a53f7892411bb 100644 (file)
@@ -4028,8 +4028,10 @@ emit_invoke_call (MonoMethodBuilder *mb, MonoMethod *method,
 
        /* to make it work with our special string constructors */
        if (!string_dummy) {
+               MonoError error;
                MONO_GC_REGISTER_ROOT_SINGLE (string_dummy, MONO_ROOT_SOURCE_MARSHAL, "dummy marshal string");
-               string_dummy = mono_string_new_wrapper ("dummy");
+               string_dummy = mono_string_new_checked (mono_get_root_domain (), "dummy", &error);
+               mono_error_assert_ok (&error);
        }
 
        if (virtual_) {