Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonojenkins <jo.shields+jenkins@xamarin.com>2020-02-20 15:01:06 +0300
committerGitHub <noreply@github.com>2020-02-20 15:01:06 +0300
commitfc145be98c719a15ed7182506185e84851803e1d (patch)
tree911dd2714f4b1347a31c589d1cde5a1499f5528d
parentadebac056a7c05329b29820ac09e8ece3ddd492f (diff)
[sgen] Disable managed allocator when using nursery-canaries (#18946)mono-6.10.0.81
The managed allocator included in a full aot image does not support canaries, leading to inconsistent object layout. Fixes https://github.com/mono/mono/issues/18925 Co-authored-by: Vlad Brezae <brezaevlad@gmail.com>
-rw-r--r--man/mono.18
-rw-r--r--mono/metadata/sgen-mono.c7
-rw-r--r--mono/sgen/sgen-gc.c2
3 files changed, 16 insertions, 1 deletions
diff --git a/man/mono.1 b/man/mono.1
index 6478fc2bcb7..d7dc065487e 100644
--- a/man/mono.1
+++ b/man/mono.1
@@ -1496,6 +1496,9 @@ scanning is available.
\fBno-managed-allocator\fR
Disables the managed allocator.
.TP
+\fBmanaged-allocator\fR
+Enables the managed allocator.
+.TP
\fBcheck-scan-starts\fR
If set, does a plausibility check on the scan_starts before and after each collection
.TP
@@ -1521,7 +1524,10 @@ sgen-gc.c. You can then use this command to explore the output
\fBnursery-canaries\fR
If set, objects allocated in the nursery are suffixed with a canary (guard)
word, which is checked on each minor collection. Can be used to detect/debug
-heap corruption issues.
+heap corruption issues. This disables the usage of the managed allocator,
+because allocation from full aot code is inconsistent with this option. If
+the application is guaranteed not to use aot code, the managed allocator can
+be enabled back with managed-allocator option.
.TP
\fBdo-not-finalize(=\fIclasses\fB)\fR
diff --git a/mono/metadata/sgen-mono.c b/mono/metadata/sgen-mono.c
index ae37cce1485..f6f90c965c0 100644
--- a/mono/metadata/sgen-mono.c
+++ b/mono/metadata/sgen-mono.c
@@ -3013,6 +3013,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/mono/sgen/sgen-gc.c b/mono/sgen/sgen-gc.c
index 78069eeb95f..e3179233bdd 100644
--- a/mono/sgen/sgen-gc.c
+++ b/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);