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:
authorg-insn <50236657+g-insn@users.noreply.github.com>2021-02-16 16:35:32 +0300
committerGitHub <noreply@github.com>2021-02-16 16:35:32 +0300
commitd6c2313a95058e9d6ee8d4b9b33cbaf9dfec1048 (patch)
tree3e64a47ad27f8d83c692acc134b7112f45ff347a
parent6a52f152e4321f61f62f699c02443b7f2e8e5801 (diff)
Don't assume result is non-NULL if its type is not TYPE_VOID when tracing. (#20832)
This change is released under the MIT license. On a CEE_MONO_ICALL set to mono_threads_detach_coop (from native to managed), the profile code is always emitted without a return value, since it's not at a ret. This means it's never set, even if there actually is a return type (other than TYPE_VOID). When tracing, it's assumed that valid result types other than TYPE_VOID can be dereferenced, even though in this case no result has been set. This causes a null dereference fault.
-rw-r--r--mono/mini/trace.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mono/mini/trace.c b/mono/mini/trace.c
index 56e19a85751..588252ca1e9 100644
--- a/mono/mini/trace.c
+++ b/mono/mini/trace.c
@@ -353,6 +353,11 @@ mono_trace_leave_method (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallCo
type = mini_get_underlying_type (mono_method_signature_internal (method)->ret);
gpointer buf = mini_profiler_context_get_result (ctx);
+ if (!buf && type->type != MONO_TYPE_VOID) {
+ printf ("result unknown");
+ goto finish;
+ }
+
switch (type->type) {
case MONO_TYPE_VOID:
break;
@@ -435,6 +440,7 @@ mono_trace_leave_method (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallCo
}
mini_profiler_context_free_buffer (buf);
+finish:
//printf (" ip: %p\n", MONO_RETURN_ADDRESS_N (1));
printf ("\n");
fflush (stdout);