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

Add support for coredumps which are stored using systemd-coredump #1181

Merged
merged 1 commit into from Feb 22, 2019

Conversation

Projects
None yet
2 participants
@jonasbb
Copy link
Contributor

jonasbb commented Aug 3, 2018

From the coredumpctl man page:

coredumpctl is a tool that can be used to retrieve and process
core dumps and metadata which were saved by systemd-coredump(8).

systemd-coredump works by setting a piped core pattern. For example:

$ cat /proc/sys/kernel/core_pattern
|/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e

This commit detects systemd-coredump in the pattern and then uses
coredumpctl, which is the CLI utility for reading the coredumps.
coredumpctl is instructed to write the coredump to a file. The
coredump is specified using the process ID and the basename of the
executable.

This commit also updates some doc strings to fix them and make them
more useful.


I kept the core in native_corefile_pipe for the apport case identical. I just changed the control flow to add another case.

I tried to keep systemd_coredump_corefile as simple as possible. The /dev/null files are requires, as otherwise coredumpctl would print quite a lot of status information about the coredump every time.

I did not add any test, because I do not know if and how that would be possible, as it would require an operating system with systemd-coredump configured. A docker container is not enough, as the /proc filesystem is mounted from the host.

This fixes both #1177 and #1178.

@jonasbb jonasbb force-pushed the jonasbb:coredumpctl-support branch 2 times, most recently from 7dbca8d to f86ee26 Aug 3, 2018

log.debug("Found systemd-coredump in core_pattern")
return self.systemd_coredump_corefile()
else:
log.warn_once("Unsupported core_pattern: %r", self.kernel_core_pattern)

This comment has been minimized.

@jonasbb

jonasbb Aug 3, 2018

Author Contributor

Switching to a , instead of the % fixes #1177.

@Arusekk
Copy link
Collaborator

Arusekk left a comment

I think that the PR is great, have you tested it on your machine? I also submitted a review of changes that may be worth considering.

self.basename,
],
stdout=open(os.devnull, 'w'),
stderr=open(os.devnull, 'w'),

This comment has been minimized.

@Arusekk

Arusekk Jan 29, 2019

Collaborator

I would suggest replacing the doubled open() call with stderr set to STDOUT

Suggested change
stderr=open(os.devnull, 'w'),
stderr=subprocess.STDOUT,
Add support for coredumps which are stored using systemd-coredump
coredumpctl is a tool that can be used to retrieve and process
core dumps and metadata which were saved by systemd-coredump(8).

systemd-coredump works by setting a piped core pattern. For example:

$ cat /proc/sys/kernel/core_pattern
|/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e

This commit detects `systemd-coredump` in the pattern and then uses
`coredumpctl`, which is the CLI utility for reading the coredumps.
`coredumpctl` is instructed to write the coredump to a file. The
coredump is specified using the process ID and the basename of the
executable.

This commit also updates some doc strings to fix them and make them
more useful.

This fixes #1177, #1178

@jonasbb jonasbb force-pushed the jonasbb:coredumpctl-support branch from f86ee26 to e625fc2 Feb 21, 2019

@jonasbb

This comment has been minimized.

Copy link
Contributor Author

jonasbb commented Feb 21, 2019

Hi @Arusekk, I included your feedback and rebased the PR to the current dev branch.

Yes I tested it locally, and it works fine.

p = process(['./crash', payload])
c = p.corefile
# [*] Process './crash' stopped with exit code -11 (SIGSEGV) (pid 17058)                                               
# [x] Parsing corefile...
# [*] '/tmp/tmp/core.17058'
#     Arch:      i386-32-little
#     EIP:       0x80491d6
#     ESP:       0x6161616e
#     Exe:       '/tmp/tmp/crash' (0x8049000)
#     Fault:     0x6161616e
# [+] Parsing corefile...: Done

@Arusekk Arusekk merged commit 224ddb4 into Gallopsled:dev Feb 22, 2019

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
Codacy/PR Quality Review Up to standards. A positive pull request.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.