From d130ebb4b9d3b66fd33c417ed341aedede76372d Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Fri, 18 Oct 2019 17:31:47 +0300 Subject: [PATCH] [profiler] Fix coverage profiler on macos (mono/mono#17396) If we have coverage profiling enabled for a method (mono_profiler_coverage_instrumentation_enabled, with coverage_filter callback), then we should be able to allocate a coverage info structure (mono_profiler_coverage_alloc). After https://github.com/mono/mono/commit/mono/mono@52429673dc617fd437518757c04c7448211075e9, coverage_filter was reporting wrapper methods as ok to profile, while mono_profiler_coverage_alloc was refusing to allocate the necessary structure, leading to crashes. Commit migrated from https://github.com/mono/mono/commit/37f628750af0f81e7550989e83bcfe3d134fb6be --- src/mono/mono/metadata/profiler.c | 5 +---- src/mono/mono/profiler/coverage.c | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mono/mono/metadata/profiler.c b/src/mono/mono/metadata/profiler.c index 190eaa0..7b6b971 100644 --- a/src/mono/mono/metadata/profiler.c +++ b/src/mono/mono/metadata/profiler.c @@ -428,10 +428,7 @@ MonoProfilerCoverageInfo * mono_profiler_coverage_alloc (MonoMethod *method, guint32 entries) { if (!mono_profiler_state.code_coverage) - return FALSE; - - if (method->wrapper_type) - return FALSE; + return NULL; if (!mono_profiler_coverage_instrumentation_enabled (method)) return NULL; diff --git a/src/mono/mono/profiler/coverage.c b/src/mono/mono/profiler/coverage.c index c46b63c..fc47fa6 100644 --- a/src/mono/mono/profiler/coverage.c +++ b/src/mono/mono/profiler/coverage.c @@ -691,6 +691,9 @@ coverage_filter (MonoProfiler *prof, MonoMethod *method) { guint32 iflags, flags; + if (method->wrapper_type) + return FALSE; + flags = mono_method_get_flags (method, &iflags); if ((iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) || -- 2.7.4