Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace is trying to dereferencing misaligned pointer #216

Open
gen-xu opened this issue Jul 14, 2023 · 3 comments
Open

trace is trying to dereferencing misaligned pointer #216

gen-xu opened this issue Jul 14, 2023 · 3 comments

Comments

@gen-xu
Copy link
Contributor

gen-xu commented Jul 14, 2023

rust panic with following error message

Thread { id: ThreadId(1), name: Some("main"), .. }: panicked at 'misaligned pointer dereference: address must be a multiple of 0x8 but is 0x7ffd57e2a81c', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/pprof-0.11.1/src/backtrace/frame_pointer.rs:107:30

after some investigation these two lines in frame_pointer.rs turned out to be the root cause

            let frame = Frame {
                ip: unsafe { (*frame_pointer).ret }, // trying to dereference misaligned pointer here
            };

            if !cb(&frame) {
                break;
            }
            frame_pointer = unsafe { (*frame_pointer).frame_pointer }; // trying to dereference misaligned pointer here
@alindima
Copy link

I'm seeing similar errors also when using pprof-rs with libunwind on Mac M2:

libunwind::CFI_Parser<libunwind::LocalAddressSpace>::decodeFDE(libunwind::LocalAddressSpace&, unsigned long, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::FDE_Info*, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::CIE_Info*, bool) (@libunwind::CFI_Parser<libunwind::LocalAddressSpace>::decodeFDE(libunwind::LocalAddressSpace&, unsigned long, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::FDE_Info*, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::CIE_Info*, bool):15)
libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::step() (@libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::step():55)
_Unwind_Backtrace (@_Unwind_Backtrace:90)
backtrace::backtrace::libunwind::trace (/Users/alindima/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/backtrace/libunwind.rs:93)
backtrace::backtrace::trace_unsynchronized (/Users/alindima/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/backtrace/mod.rs:66)
<pprof::backtrace::backtrace_rs::Trace as pprof::backtrace::Trace>::trace (/Users/alindima/Desktop/code/pprof-rs/src/backtrace/backtrace_rs.rs:23)
perf_signal_handler (/Users/alindima/Desktop/code/pprof-rs/src/profiler.rs:291)
_sigtramp (@_sigtramp:17)
...

@DavidBJaffe
Copy link

I got the same error message. This is on an Apple M1 Pro running OSX 13.5.2 and Rust 1.72.0. I am fairly confident that the behavior changed upon OSX upgrade, although I'm not sure which upgrade, and hypothetically the behavior could have changed when I upgraded Rust. Regardless, profiling always crashes now.

@YangKeao
Copy link
Member

I got the same error message. This is on an Apple M1 Pro running OSX 13.5.2 and Rust 1.72.0. I am fairly confident that the behavior changed upon OSX upgrade, although I'm not sure which upgrade, and hypothetically the behavior could have changed when I upgraded Rust. Regardless, profiling always crashes now.

I'm getting a Macbook today. Maybe I can try to reproduce the bug on it 😆 .

The backtrace provided by @alindima above is really helpful and I think I have known the problem, just need to verify / validate the fix 🍻 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants