diff options
author | Rodrigo Kumpera <kumpera@users.noreply.github.com> | 2017-02-24 00:14:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-24 00:14:23 +0300 |
commit | 26748dcdbfbdd974d82b0d7c79b575d339b4bb7d (patch) | |
tree | 94bf50a26e6a70a16fb55df3824c62b655108519 | |
parent | b36c8440d3dc55be51d86207437b87ed8b2b34e6 (diff) | |
parent | 0fc4608b1b0e9ad8eb03f581dce7c568bbd67393 (diff) |
Merge pull request #4419 from BrzVlad/fix-oom-nre
[sgen] Fix oom nre
-rw-r--r-- | mono/metadata/sgen-mono.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/mono/metadata/sgen-mono.c b/mono/metadata/sgen-mono.c index fc82365a933..e8dd50b13d7 100644 --- a/mono/metadata/sgen-mono.c +++ b/mono/metadata/sgen-mono.c @@ -1051,7 +1051,7 @@ create_allocator (int atype, ManagedAllocatorVariant variant) { int p_var, size_var, real_size_var, thread_var G_GNUC_UNUSED; gboolean slowpath = variant == MANAGED_ALLOCATOR_SLOW_PATH; - guint32 slowpath_branch, max_size_branch; + guint32 fastpath_branch, max_size_branch, no_oom_branch; MonoMethodBuilder *mb; MonoMethod *res; MonoMethodSignature *csig; @@ -1318,7 +1318,7 @@ create_allocator (int atype, ManagedAllocatorVariant variant) /* if (G_LIKELY (new_next < tlab_temp_end)) */ mono_mb_emit_ldloc (mb, new_next_var); EMIT_TLS_ACCESS_TEMP_END (mb, thread_var); - slowpath_branch = mono_mb_emit_short_branch (mb, MONO_CEE_BLT_UN_S); + fastpath_branch = mono_mb_emit_short_branch (mb, MONO_CEE_BLT_UN_S); /* Slowpath */ if (atype != ATYPE_SMALL) @@ -1353,10 +1353,17 @@ create_allocator (int atype, ManagedAllocatorVariant variant) } else { g_assert_not_reached (); } + + /* if (ret == NULL) throw OOM; */ + mono_mb_emit_byte (mb, CEE_DUP); + no_oom_branch = mono_mb_emit_branch (mb, CEE_BRTRUE); + mono_mb_emit_exception (mb, "OutOfMemoryException", NULL); + + mono_mb_patch_branch (mb, no_oom_branch); mono_mb_emit_byte (mb, CEE_RET); /* Fastpath */ - mono_mb_patch_short_branch (mb, slowpath_branch); + mono_mb_patch_short_branch (mb, fastpath_branch); /* FIXME: Memory barrier */ |