Merge pull request #757 from mlintner/master
[mono.git] / mono / mini / mini.c
index 2df38aa943aa213e9d78c714c3b737abeafb2a4c..607c627462d74ae7c6b9b7ad68963a47076726ef 100644 (file)
@@ -3127,6 +3127,20 @@ mono_insert_safepoints (MonoCompile *cfg)
                return;
        }
 
+       if (cfg->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) {
+               WrapperInfo *info = mono_marshal_get_wrapper_info (cfg->method);
+
+               if (info && info->subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER &&
+                       (info->d.icall.func == mono_thread_interruption_checkpoint ||
+                       info->d.icall.func == mono_threads_finish_blocking ||
+                       info->d.icall.func == mono_threads_reset_blocking_start)) {
+                       /* These wrappers are called from the wrapper for the polling function, leading to potential stack overflow */
+                       if (cfg->verbose_level > 1)
+                               printf ("SKIPPING SAFEPOINTS for wrapper %s\n", cfg->method->name);
+                       return;
+               }
+       }
+
        if (cfg->verbose_level > 1)
                printf ("INSERTING SAFEPOINTS\n");
        if (cfg->verbose_level > 2)