-
Notifications
You must be signed in to change notification settings - Fork 128
Capture c++ stack traces from core dump files on linux #38600
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
Capture c++ stack traces from core dump files on linux #38600
Conversation
e3ba601
to
8569ea0
Compare
b0238c0
to
83de376
Compare
The release note structure for v6.13 has been created. You can now rebase your branch and move the release note in this PR. |
272df8c
to
cbc3bdd
Compare
8b6f084
to
2bbc225
Compare
👋 Hi, @jhaigh0, Conflicts have been detected against the base branch. Please rebase your branch against the base branch. |
👋 Hi, @jhaigh0, Conflicts have been detected against the base branch. Please rebase your branch against the base branch. |
885c47e
to
e5d9b18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following test instruction number three here should give me a python stacktrace, but it seems to be lost now.
e5d9b18
to
65df9e8
Compare
qt/python/mantidqt/mantidqt/dialogs/errorreports/run_pystack.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've verified that C++ stack traces are picked up on Linux, and the Python stack traces are still working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, but could it work on macOS as well?
I think it could work on mac too. I was focused on linux for the first version because it's what I had to test on + the majority of our users. If you think it's as simple as replacing the |
Yes I think it'll work just by changing the if statements, but it can wait for a separate PR |
…#38600) * add pystack to workbench and developer environments * Turn on core dumps on linux for the inner workbench process Has to switch from multiprocessing to subprocess in order to do this (needed the preexec option). Through some testing, this should preserve the desired spawn behaviour. A new module 'workbench_process.py' has been created to use with subprocess.run (can't pass it a function) * add module to get the compressed output from pystack on the latest worbench core file * add tests for new run pystack module * add cpp traces to the report sender * base64 encode data to store as a string * show pystack output in the show more details window * add release note * update existing tests * fix pystack test * add support for lz4 compressed core files, such as those on idaaas * only import lz4 if on linux * return Path type as intended * use process id to identify core dump file * move release note to 6.13 * pass missing parameter to errorreporter constructor * only launch with preexec_func when not on windows to avoid crash * add property to user properties default file * Update comment in run_pystack --------- Co-authored-by: thomashampson <thomas.hampson@stfc.ac.uk>
* Fix some cppcheck warnings * Capture c++ stack traces from core dump files on linux (#38600) * add pystack to workbench and developer environments * Turn on core dumps on linux for the inner workbench process Has to switch from multiprocessing to subprocess in order to do this (needed the preexec option). Through some testing, this should preserve the desired spawn behaviour. A new module 'workbench_process.py' has been created to use with subprocess.run (can't pass it a function) * add module to get the compressed output from pystack on the latest worbench core file * add tests for new run pystack module * add cpp traces to the report sender * base64 encode data to store as a string * show pystack output in the show more details window * add release note * update existing tests * fix pystack test * add support for lz4 compressed core files, such as those on idaaas * only import lz4 if on linux * return Path type as intended * use process id to identify core dump file * move release note to 6.13 * pass missing parameter to errorreporter constructor * only launch with preexec_func when not on windows to avoid crash * add property to user properties default file * Update comment in run_pystack --------- Co-authored-by: thomashampson <thomas.hampson@stfc.ac.uk> --------- Co-authored-by: James Clarke <james.clarke@stfc.ac.uk> Co-authored-by: Jonathan Haigh <35813666+jhaigh0@users.noreply.github.com> Co-authored-by: thomashampson <thomas.hampson@stfc.ac.uk>
Description of work
Adds the recovery of C++ stack trace information in the event of a crash on linux.
subprocess.Popen
(rather thanmultiprocessing
) to make use of thepre_exec_func
parameter. This is passed a function which turns on core dumps for the workbench process.errorreports.core_dumps
will need to be set for this feature to work. This is a path to the directory in which your linux system places core dump files. I couldn't find a reliable method to determine this automatically, an alternative would be to setsysctl -w kernel.core_pattern=/tmp/mantid_core_dumps
in the pre-exec function. Couldn't find a python exposed way of doing this though (other than callingsubprocess.run
)pystack
library which can recover trace backs from all active threads.pystack
produces a lot of output, the data is sent compressed to the error reporter.lz4
compressed, so that case has been considered.Fixes #38405
Further detail of work
The error reporter won't know about this change until mantidproject/errorreports#60 is merged since the C++ traces are assigned to a new variable. Either can be merged first safely.
On a built version, pystack won't recover the file names of out C++ code, but it will recover the function names and call stacks.
To test:
https://builds.mantidproject.org/job/build_packages_from_branch/1068/artifact/
conda install jhaigh0/label/core_dump_test::mantidworkbench
(make sure it is6.12.20250325.1517-py310hd83431c_0
)errorreports.core_dumps
to be where core dumps end up on your system. If it's ubuntu then it's probably/var/lib/apport/coredump
(On IDAaaS/var/lib/systemd/coredump
and you want to set it in/etc/mantid.local.properties
probably)Segfault::exec()
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.