diff options
author | Zoltan Varga <vargaz@gmail.com> | 2020-09-04 00:56:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 00:56:24 +0300 |
commit | 5756e65a5c23784e68b494eb4b332e0eb647f40c (patch) | |
tree | a516882e5ca1b092574c2b5f14f981e3375f3936 | |
parent | dfd7ba8ff6598140a89356a7fe01f5c5fc348a10 (diff) |
[runtime] Allocate code memory using MAP_JIT on apple silicon, patching code randomly crashes without it. (#20342)
-rw-r--r-- | mono/utils/mono-mmap.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mono/utils/mono-mmap.c b/mono/utils/mono-mmap.c index 2dff889c4ca..fa4686f0aca 100644 --- a/mono/utils/mono-mmap.c +++ b/mono/utils/mono-mmap.c @@ -305,6 +305,9 @@ mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type) } if ((flags & MONO_MMAP_JIT) && (use_mmap_jit || is_hardened_runtime == 1)) mflags |= MAP_JIT; + /* Patching code on apple silicon seems to cause random crashes without this flag */ + if (__builtin_available (macOS 11, *)) + mflags |= MAP_JIT; } #endif |