Open Bug 1910609 Opened 2 years ago Updated 1 year ago

Crash when profiling with native allocations

Categories

(Core :: Gecko Profiler, defect, P3)

defect

Tracking

()

People

(Reporter: nical, Unassigned)

References

Details

(Whiteboard: [sp3])

Crash Data

Crash report: https://crash-stats.mozilla.org/report/index/10ccd6d1-ccfa-40b3-b270-97b800240730

I hit the same crash reliably if the profiler settings include "native allocations".

Hey nical !
Would you be able to upload a pernosco run of that?

To me this rings a bell with bug 1753976

See Also: → 1753976

(ni just in case you get a chance to capture a pernosco session)

Severity: -- → S3
Flags: needinfo?(nical.bugzilla)
Priority: -- → P3
Duplicate of this bug: 1917205

Copying crash signatures from duplicate bugs.

Crash Signature: [@ Mutex::Lock]
No longer duplicate of this bug: 1917205

Caught this under rr and made a pernosco: https://pernos.co/debug/GrWGGGBFGWdPECGSJ8GN-A/index.html, clearing nical's NI and adding another one for Nazım.

Flags: needinfo?(nical.bugzilla) → needinfo?(canaltinova)

It looks like we try to add a marker and capture a stack while the thread is unregistered, this doesn't look right.

See Also: → 1919685
Duplicate of this bug: 1919685

This is the information Paul provided in Bug 1919685:

I see this crash when capturing native allocation:

#01: WasmTrapHandler(int, siginfo_t*, void*) (/mnt/dev/moz/prof_hook/js/src/wasm/WasmSignalHandlers.cpp:796)
#02: ??? (/lib/x86_64-linux-gnu/libc.so.6 + 0x3c050)
#03: DoSharedSample(bool, unsigned int, mozilla::profiler::ThreadRegistrationUnlockedReaderAndAtomicRWOnThread const&, JS::ProfilingFrameIterator::Frame*, Registers const&, unsigned long, unsigned long, ProfileBuffer&, mozilla::StackCaptureOptions) (/mnt/dev/moz/prof_hook/tools/profiler/core/platform.cpp:2932)
#04: profiler_capture_backtrace_into(mozilla::ProfileChunkedBuffer&, mozilla::StackCaptureOptions)::$_0::operator()(mozilla::profiler::ThreadRegistration::OnThreadRef) const (/mnt/dev/moz/prof_hook/tools/profiler/core/platform.cpp:7679)
#05: profiler_capture_backtrace_into(mozilla::ProfileChunkedBuffer&, mozilla::StackCaptureOptions) (/mnt/dev/moz/prof_hook/tools/profiler/core/platform.cpp:7662)
#06: mozilla::profiler::profiler_add_native_allocation_marker(long, unsigned long) (/mnt/dev/moz/prof_hook/tools/profiler/core/memory_hooks.cpp:113)
#07: mozilla::profiler::AllocCallback(void*, unsigned long) (/mnt/dev/moz/prof_hook/tools/profiler/core/memory_hooks.cpp:417)
#08: replace_malloc(unsigned long) (/mnt/dev/moz/prof_hook/tools/profiler/core/memory_hooks.cpp:478)
#09: moz_xmalloc (/mnt/dev/moz/prof_hook/memory/mozalloc/mozalloc.cpp:53)
#10: ProfilingStack::ensureCapacitySlow() (/mnt/dev/moz/prof_hook/js/src/vm/ProfilingStack.cpp:41)
[Parent 1216454, IPC I/O Parent] WARNING: [1.1]: Dropping message '<null>'; no connection to unknown peer F0B71BB5A460A027.94D72400492E40E2: file /mnt/dev/moz/prof_hook/ipc/glue/NodeController.cpp:364
#11: nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) (/mnt/dev/moz/prof_hook/xpcom/components/nsComponentManager.cpp:1166)
#12: nsGetServiceByContractID::operator()(nsID const&, void**) const (/mnt/dev/moz/prof_hook/xpcom/components/nsComponentManagerUtils.cpp:241)
#13: WatchdogMain(void*) (/mnt/dev/moz/prof_hook/js/xpconnect/src/XPCJSContext.cpp:521)
#14: _pt_root (/mnt/dev/moz/prof_hook/nsprpub/pr/src/pthreads/ptthread.c:204)
#15: set_alt_signal_stack_and_start(PthreadCreateParams*) (/mnt/dev/moz/prof_hook/mozglue/interposers/pthread_create_interposer.cpp:81)
#16: ??? (/lib/x86_64-linux-gnu/libc.so.6 + 0x89144)
#17: ??? (/lib/x86_64-linux-gnu/libc.so.6 + 0x1097dc)
#18: ??? (???:???)

Using a recent build from mercurial, with Bug 1917205 applied, running on Linux on amd64.

STR:

  1. Open firefox
  2. Visit profiler.firefox.com to enable the profiler, (click the button there etc).
  3. Click the little arrow next to the profiler symbol in the toolbar,
  4. Choose Edit Settings
  5. Enable "Memory Tracking" and "Native Allocations"
  6. Start capturing with the profiler.
  7. Visit reddit.com or similarly "sufficiently complex" website and look around for a minute.
  8. The browser or a process should crash in about 15 seconds. Well, it shouldn't, that's the observed behaviour.

This is a different signature from Bug 1917205, I don't believe they're related except that they're in the same feature and Bug 1917205 crashed at an earlier point masking this problem.

I can also reproduce it locally. Here's a crash reporter entry with the correct stacks:
https://crash-stats.mozilla.org/report/index/4ab8f05f-73a5-4aa8-b448-453580241014

It does seem weird. I will look into it a bit more.

Flags: needinfo?(canaltinova)
Blocks: 1806054
Whiteboard: [sp3]
Crash Signature: [@ Mutex::Lock] → [@ Mutex::Lock] [@ DoSharedSample ]

I wanted to use the native allocations feature today, and encountered this once again :-(

Nazim and I had a look at the Pernosco trace, and it looks like the crash is coming from a huge allocation in the function prelude for DoSharedSample. Looking at the code, we seem to be trying to allocate 180kb of memory, and zero-ing it out. We crash after a few iterations of zero-ing the data. We think that this might be from the ProfilerNativeStack object that we allocate (which is 16kb), but that's still only a small part of the 180kb that we need to track down.

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