RudjiGames / MTuner

MTuner is a C/C++ memory profiler and memory leak finder for Windows, PlayStation 4 and 3, Android and other platforms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getStackTrace() sometimes returns empty stacktrace resulting "Capture file was only partially loaded!"

ikrima opened this issue · comments

Been chasing a nondeterministic bug where the trace file gets corrupted for a couple of days
Finally found culprit to be RtlCaptureStackBackTrace() sometimes returning 0/no stacktrace

Some odd tidbbits:

  • Platform is x64 (and debug builds) so Frame Pointer omission isn't the cause
  • Replacing all __forceinline with inline solves the problem. The triggering code usually has a callstack with a lambda & a function that was __forceinlined. This doesn't make any sense but putting it out there
  • For now, i hacked a workaround by, which makes less sense that it works ¯\(ツ)
uint32_t numTraces = getStackTrace(backTrace, RMEM_STACK_TRACE_MAX, 0);
numTraces = numTraces ? numTraces : getStackTrace(backTrace, RMEM_STACK_TRACE_MAX, 0);

Any ideas/thoughts as to what's going on? Maybe someone has some insight before having to dive into RtlCaptureStackBackTrace() internals

Thank you for chasing this one. Frankly, I have no idea why it would return zero/no trace or succeed on a repeated call :/
I may look at this at some point but swamped with other things at the moment

No worries! The workaround is pretty stable so it's not super critical; just very perplexed by the behavior so i'll probably step away from it for a bit and resume my investigation with fresh eyes