Open Bug 1695618 Opened 4 years ago Updated 3 years ago

profiler_capture_backtrace_into with DoMozStackWalkBacktrace sometimes adds a leaf function that will be re-captured during stack walking

Categories

(Core :: Gecko Profiler, defect, P3)

defect

Tracking

()

People

(Reporter: mozbugz, Unassigned)

References

Details

Stacks captured in markers may look like this: (Only leaf functions, for brevity)

...
base_profiler_markers_detail::AddMarkerToBuffer
profiler_capture_backtrace_into
DoSharedSample
DoMozStackWalkBacktrace
profiler_capture_backtrace_into

Notice that profiler_capture_backtrace_into is present twice!

This is because registers are captured in profiler_capture_backtrace_into, then they are passed to DoSyncSample, then DoSharedSample, DoNativeBacktrace, and finally DoMozStackWalkBacktrace where the registers are added straight away as the leaf frame!
After that, MozStackWalkThread will start a full stack walk without looking at the registers, which is why we see a few deeper calls before encountering profiler_capture_backtrace_into again.

My immediate thought would be to simply remove the first StackWalkCallback from DoMozStackWalkBacktrace, but I'm not sure if there aren't some situations in which it would be necessary to keep, so I'll need more time to examine this.
Ideas welcome!

This is fairly low priority, because the new PROFILER category actually ends up hiding these leaf functions, including both profiler_capture_backtrace_intos, so this issue is not visible in the profiler front-end.
But it would still be nice to correct, especially in case other callers would need the extra frames.

"See also" bug 1714501: Registers::SyncPopulate is used incorrectly and will need to be forcefully inlined, or removed (or something else).
This may be an opportunity to look at the related issue here, to see if we really need to use the Registers::SyncPopulate information as leaf frame in profiler backtraces.

You need to log in before you can comment on or make changes to this bug.