Skip to content

Commit 3d68402

Browse files
authored
Rollup merge of #52333 - kennytm:linux-core-dump, r=alexcrichton
CI: Enable core dump on Linux, and print their stack trace on segfault.
2 parents fe64419 + 1e1b800 commit 3d68402

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

.travis.yml

+25-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ sudo: required
33
dist: trusty
44
services:
55
- docker
6+
addons:
7+
apt:
8+
packages:
9+
- gdb
610

711
git:
812
depth: 2
@@ -249,6 +253,8 @@ before_script:
249253
export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh";
250254
else
251255
export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE";
256+
# Enable core dump on Linux.
257+
sudo sh -c 'echo "/checkout/obj/cores/core.%p.%E" > /proc/sys/kernel/core_pattern';
252258
fi
253259
254260
# Log time information from this machine and an external machine for insight into possible
@@ -274,6 +280,8 @@ after_failure:
274280
275281
# Random attempt at debugging currently. Just poking around in here to see if
276282
# anything shows up.
283+
284+
# Dump backtrace for macOS
277285
- ls -lat $HOME/Library/Logs/DiagnosticReports/
278286
- find $HOME/Library/Logs/DiagnosticReports
279287
-type f
@@ -284,8 +292,24 @@ after_failure:
284292
-exec head -750 {} \;
285293
-exec echo travis_fold":"end:crashlog \; || true
286294

295+
# Dump backtrace for Linux
296+
- ln -s . checkout &&
297+
for CORE in obj/cores/core.*; do
298+
EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|');
299+
if [ -f "$EXE" ]; then
300+
printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE";
301+
gdb -q -c "$CORE" "$EXE"
302+
-iex 'set auto-load off'
303+
-iex 'dir src/'
304+
-iex 'set sysroot .'
305+
-ex bt
306+
-ex q;
307+
echo travis_fold":"end:crashlog;
308+
fi;
309+
done || true
310+
287311
# see #50887
288-
- head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
312+
- cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
289313

290314
# attempt to debug anything killed by the oom killer on linux, just to see if
291315
# it happened

src/ci/docker/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ objdir=$root_dir/obj
9999

100100
mkdir -p $HOME/.cargo
101101
mkdir -p $objdir/tmp
102+
mkdir $objdir/cores
102103

103104
args=
104105
if [ "$SCCACHE_BUCKET" != "" ]; then

src/ci/run.sh

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ if [ "$NO_CHANGE_USER" = "" ]; then
2424
fi
2525
fi
2626

27+
# only enable core dump on Linux
28+
if [ -f /proc/sys/kernel/core_pattern ]; then
29+
ulimit -c unlimited
30+
fi
31+
2732
ci_dir=`cd $(dirname $0) && pwd`
2833
source "$ci_dir/shared.sh"
2934

0 commit comments

Comments
 (0)