Skip to content

Commit 26594d2

Browse files
authored
[wf-macos] Enable core dump upload on SEGV (#4829)
Extracted from #4343
2 parents 048f0fb + 05a3f98 commit 26594d2

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/macos.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,43 @@ jobs:
229229
- name: Build
230230
run: cmake --build ${{ env.BUILD_DIR }}
231231

232+
- name: Enable core dump generation
233+
working-directory: ${{ env.BUILD_DIR }}
234+
shell: bash
235+
run : |
236+
# Allow core dumps
237+
sudo sysctl -w kern.coredump=1
238+
# This entitlement is needed for a proc to produce a coredump
239+
/usr/libexec/PlistBuddy -c "Add :com.apple.security.get-task-allow bool true" segv.entitlements
240+
# Code-sign the test executable to grant core dump entitlement
241+
codesign -s - -f --entitlements segv.entitlements bin/multipass_tests
242+
# Ensure destination exists and is writable
243+
sudo mkdir -p /cores || true
244+
sudo chmod 1777 /cores
245+
# Print syctl coredump parameters
246+
sysctl kern.coredump kern.corefile
247+
ulimit -a
248+
ulimit -Hc
249+
232250
- name: Test
233251
working-directory: ${{ env.BUILD_DIR }}
234252
run: |
253+
# Catch and save the test executable's exit code
254+
trap 'echo "MULTIPASS_TESTS_EXIT_CODE=$?" >> $GITHUB_ENV' EXIT
255+
# Set soft limit for the core file size (512MiB)
256+
ulimit -c 1048576
235257
bin/multipass_tests
236258
259+
- name: Upload test coredump
260+
uses: actions/upload-artifact@v4
261+
if: ${{ failure() && env.MULTIPASS_TESTS_EXIT_CODE != '0' }}
262+
with:
263+
name: buildandtest-test-crash-${{ matrix.runs-on }}-${{ matrix.build-type }}
264+
retention-days: 7
265+
path: |
266+
/cores/**
267+
${{ env.BUILD_DIR }}/bin/multipass_tests
268+
237269
- name: Package
238270
id: cmake-package
239271
working-directory: ${{ env.BUILD_DIR }}

0 commit comments

Comments
 (0)