Description
This is somewhat relate to #370, as it seems impossible to test them separately, but I believe it a separate issue.
It seems if a raw profiler chooses to rewrite a method but it hasn't been rewritten by an instrumentation method then an null ref will occur, or rather the functions will start to return fail HRESULTs because of a null ref.
For an existing method that has been instrumented by the raw profiler but not an instrumentation method CCorProfilerInfoWrapper::GetILFunctionBody
will call pMethodInfo->GetIntermediateRenderedFunctionBody
. This because pMethodInfo->IsInstrumented()
has been set when CMethodInfo::SetFinalRenderedFunctionBody
was called.
This means that we're in a state where m_bIsInstrumented
is true, m_pIntermediateRenderedMethod
is null and m_pFinalRenderedMethod
is set to a valid method body.
So, our CMethodInfo
has a valid method body, but I'm not sure what the correct way to retrieve it.
One possible fix is to update CMethodInfo::SetFinalRenderedFunctionBody
so that it sets m_pIntermediateRenderedMethod
if it is not already set. I believe this works, but can't test it properly because of the other issue: robertpi@22b96b5#diff-9025cfc4efbe6666f69f6103e8d4aca595e5107e7c0ec46d644b3f34345717c9R1314
There maybe other better ways to fix this.