Skip to content

Enhance CI script to check for core file generation and improve logging in corefile extraction process. #2571

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,21 @@ jobs:
ulimit -c unlimited
cat /proc/sys/kernel/core_pattern
cat /proc/sys/kernel/core_uses_pid
( cd $(mktemp -d); sh -c 'kill -11 $$' || true; ls -la ./*core* /var/crash/*.crash /var/lib/apport/coredump/core*) || true
# Create a temporary directory for the test
TEST_DIR=$(mktemp -d)
cd $TEST_DIR

# Run a command that will generate a segfault
sh -c 'kill -11 $$' || true

# Check for core files in various locations
echo "Looking for core files in various locations:"
if ls -la ./*core* /var/crash/*.crash /var/lib/apport/coredump/core* 2>/dev/null; then
echo "SUCCESS: Core file found"
else
echo "ERROR: No core file found"
exit 1
fi

- name: Set up SSH
run: |
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ The table below shows which release corresponds to each branch, and what date th
- [#2504][2504] doc: add example case for `tuple` (host, port pair) in `gdb.attach`
- [#2546][2546] ssh: Allow passing disabled_algorithms keyword argument from ssh to paramiko
- [#2538][2538] Add `ssh -L` / `ssh.connect_remote()` workaround when `AllowTcpForwarding` is disabled
- [#2571][2571] Improve CI test for core file generation to fail if no core file is found
- [#2571][2571] Add better logging for systemd-coredump extraction in CorefileFinder

[2551]: https://github.com/Gallopsled/pwntools/pull/2551
[2519]: https://github.com/Gallopsled/pwntools/pull/2519
Expand All @@ -104,6 +106,7 @@ The table below shows which release corresponds to each branch, and what date th
[2504]: https://github.com/Gallopsled/pwntools/pull/2504
[2546]: https://github.com/Gallopsled/pwntools/pull/2546
[2538]: https://github.com/Gallopsled/pwntools/pull/2538
[2571]: https://github.com/Gallopsled/pwntools/pull/2571

## 4.15.0 (`beta`)

Expand Down
4 changes: 4 additions & 0 deletions pwnlib/elf/corefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,7 @@ def systemd_coredump_corefile(self):
"""
filename = "core.%s.%i.coredumpctl" % (self.basename, self.pid)
try:
log.debug("Attempting to extract core dump with coredumpctl for PID %d" % self.pid)
subprocess.check_call(
[
"coredumpctl",
Expand All @@ -1363,9 +1364,12 @@ def systemd_coredump_corefile(self):
stderr=subprocess.STDOUT,
shell=False,
)
log.debug("Successfully extracted core dump to %s" % filename)
return filename
except subprocess.CalledProcessError as e:
log.debug("coredumpctl failed with status: %d" % e.returncode)
except Exception as e:
log.debug("coredumpctl failed with exception: %s" % e)

def native_corefile(self):
"""Find the corefile for a native crash.
Expand Down
Loading