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

test_coredump: fix unaligned pointer dereference #657

Merged

Conversation

karolinepauls
Copy link
Contributor

@karolinepauls karolinepauls commented Mar 9, 2024

This fixes the test but I still cannot get a coredump to load locally - the executable cannot be located in it, same goes for any other dump I tried. I'll add details in a comment.

The panic observed on master.

$ cargo test test_coredump
   Compiling py-spy v0.3.14 (/home/karoline/IDE/py-spy)
    Finished test [unoptimized + debuginfo] target(s) in 4.80s
     Running unittests src/lib.rs (target/debug/deps/py_spy-6453fb3149eb3ee2)

running 1 test
thread 'coredump::test::test_coredump' panicked at src/coredump.rs:94:30:
misaligned pointer dereference: address must be a multiple of 0x8 but is 0x7fa7adbaa334
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_nounwind_fmt::runtime
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:110:18
   2: core::panicking::panic_nounwind_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:122:9
   3: core::panicking::panic_misaligned_pointer_dereference
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:221:5
   4: py_spy::coredump::CoreDump::new
             at ./src/coredump.rs:94:30
   5: py_spy::coredump::test::test_coredump
             at ./src/coredump.rs:438:20
   6: py_spy::coredump::test::test_coredump::{{closure}}
             at ./src/coredump.rs:434:23
   7: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
   8: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread caused non-unwinding panic. aborting.
error: test failed, to rerun pass `--lib`

Caused by:
  process didn't exit successfully: `/home/karoline/IDE/py-spy/target/debug/deps/py_spy-6453fb3149eb3ee2 test_coredump` (signal: 6, SIGABRT: process abort signal)
In [1]: 0x7fa7adbaa334 % 8
Out[1]: 4
$ cargo rustc --bin py-spy -- -V
   Compiling py-spy v0.3.14 (/home/karoline/IDE/py-spy)
rustc 1.76.0 (07dca489a 2024-02-04)
$ uname -a
Linux hostname 5.15.0-97-lowlatency #107-Ubuntu SMP PREEMPT Fri Feb 9 11:16:34 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

@karolinepauls
Copy link
Contributor Author

Separate issue - inability to load a coredump (created on the same machine):

Here it seems the executable segment isn't found (added dbg statements printing program headers). I checked the section headers as well - not found there as well. But that's a separate problem. I'm not actually sure if the coredump feature is finished. I was using a coredump generated from a running python -m http.server process.

Should I create an issue for that?

/proc/pid/maps on the right side
image

@npanpaliya
Copy link

Thanks @karolinepauls . This PR is still needed to fix a test case on linux/ppc64le architecture. Can we consider merging this?

Copy link
Owner

@benfred benfred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - thanks for the PR!

@benfred benfred merged commit 6ff51b6 into benfred:master Oct 15, 2024
185 checks passed
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

Successfully merging this pull request may close these issues.

3 participants