diff --git a/src/mono/mono/metadata/sgen-mono.c b/src/mono/mono/metadata/sgen-mono.c index 3004faf16a1014..038f435c4ba048 100644 --- a/src/mono/mono/metadata/sgen-mono.c +++ b/src/mono/mono/metadata/sgen-mono.c @@ -3018,6 +3018,13 @@ sgen_client_handle_gc_debug (const char *opt) mono_log_finalizers = TRUE; } else if (!strcmp (opt, "no-managed-allocator")) { sgen_set_use_managed_allocator (FALSE); + } else if (!strcmp (opt, "managed-allocator")) { + /* + * This option can be used to override the disabling of the managed allocator by + * the nursery canaries option. This can be used when knowing for sure that no + * aot code will be used by the application. + */ + sgen_set_use_managed_allocator (TRUE); } else if (!sgen_bridge_handle_gc_debug (opt)) { return FALSE; } diff --git a/src/mono/mono/sgen/sgen-gc.c b/src/mono/mono/sgen/sgen-gc.c index 03b2b9ec034689..9071837fbc5a6d 100644 --- a/src/mono/mono/sgen/sgen-gc.c +++ b/src/mono/mono/sgen/sgen-gc.c @@ -3730,6 +3730,8 @@ sgen_gc_init (void) } else if (!strcmp (opt, "nursery-canaries")) { do_verify_nursery = TRUE; enable_nursery_canaries = TRUE; + /* If aot code is used, allocation from there won't expect the layout with canaries enabled */ + sgen_set_use_managed_allocator (FALSE); } else if (!sgen_client_handle_gc_debug (opt)) { sgen_env_var_error (MONO_GC_DEBUG_NAME, "Ignoring.", "Unknown option `%s`.", opt);