tikv / pprof-rs

A Rust CPU profiler implemented with the help of backtrace-rs
Apache License 2.0
1.29k stars 99 forks source link

Crash On M1 Mac #187

Open 0xtyls opened 1 year ago

0xtyls commented 1 year ago

I integrate pprof-rs into my own application and provide a http server like tikv did. When I request on http://ip:port/debug/pprof/profile?seconds=10, the application crashes. Here is the crash report from Mac Console:

Code Type: ARM-64 (Native) OS Version: macOS 12.3.1 (21E258) Crashed Thread: 1 tokio-runtime-worker

Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001abf9774c Exception Note: EXC_CORPSE_NOTIFY

Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5 Terminating Process: exc handler [63517]

Thread 0:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x1a144c290 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1a148683c _pthread_cond_wait + 1236 2 xxx 0x103001588 0x102eb0000 + 1381768 3 xxx 0x10336a518 0x102eb0000 + 4957464 4 xxx 0x103155d38 0x102eb0000 + 2776376 5 xxx 0x1031105ac 0x102eb0000 + 2491820 6 xxx 0x103154954 0x102eb0000 + 2771284 7 dyld 0x1039ed088 start + 516

Thread 1 Crashed:: tokio-runtime-worker 0 libunwind.dylib 0x1abf9774c libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::step() + 636 1 libunwind.dylib 0x1abf97500 libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::step() + 48 2 libunwind.dylib 0x1abf9a138 _Unwind_Backtrace + 352 3 xxx 0x103004028 0x102eb0000 + 1392680 4 libsystem_platform.dylib 0x1a149d4c4 _sigtramp + 56 5 ??? 0xffff8001a1294c08 ??? ......

YangKeao commented 1 year ago

See https://github.com/tikv/pprof-rs/issues/131#issuecomment-1146991294. I think they are the same problem :thinking:

0xtyls commented 1 year ago

Thanks for your reply. By adding "frame-pointer" in the feature list, the profile is generated. But the graph does not show anything useful. See the graph below.

image

Rustin170506 commented 1 year ago

Thanks for your reply. By adding "frame-pointer" in the feature list, the profile is generated. But the graph does not show anything useful. See the graph below.

It works well on my M1 Mac. Could you please provide a minimal project that I can help test and run it?

szandara commented 11 months ago

I have a related issue

'misaligned pointer dereference: address must be a multiple of 0x10 but is 0x16b1ff168', /Users/zandaras/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pprof-0.12.1/src/profiler.rs:330:36

Any idea? it works on Intel

YangKeao commented 11 months ago

@szandara

For this problem: "misaligned pointer dereference", I think it has been fixed in 0.12.1 (https://github.com/tikv/pprof-rs/pull/217). Please check whether you have upgraded it to the latest version 🍻

andrehp commented 11 months ago

@YangKeao I had the same issue as @szandara , running version 0.12.1:

thread 'main' panicked at 'misaligned pointer dereference: address must be a multiple of 0x10 but is 0x16ef53a58', /Users/andrehahn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pprof-0.12.1/src/profiler.rs:330:36

I'm trying to find a small sample to reproduce the issue, but a new project with the bare minimum doesn't have this issue. When testing with the codebase that throws this error, it happens even in the main function before anything else is done, but doesn't happen when I remove some parts, I'm still trying to find the culprit.