Skip to content

Commit 137f76f

Browse files
committed
ci: Enable coredump
1 parent cf57116 commit 137f76f

File tree

4 files changed

+80
-19
lines changed

4 files changed

+80
-19
lines changed

.travis.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
dist: xenial
22
services:
33
- docker
4-
language: generic
4+
language: minimal
5+
addons:
6+
apt:
7+
packages:
8+
- gdb
59

610
git:
711
depth: false
@@ -55,8 +59,8 @@ matrix:
5559
env: MACOSX_DEPLOYMENT_TARGET=10.7 TARGET=i686-apple-darwin
5660

5761
install:
58-
- sh rustup-init.sh --default-toolchain=stable -y
59-
- export PATH="$PATH:$HOME/.cargo/bin"
62+
- sh ./rustup-init.sh --default-toolchain=stable -y
63+
- . "$HOME/.cargo/env"
6064
- if [ -z "$NO_ADD" ]; then rustup target add "$TARGET"; fi
6165
- rustup component add rustfmt
6266

@@ -71,12 +75,45 @@ script:
7175
if [ -n "$DOCKER" ]; then
7276
sh ci/build-run-docker.sh "$DOCKER" "$TARGET" "$SKIP_TESTS";
7377
else
74-
PATH="$HOME/rust/bin:$PATH" sh ci/run.sh;
78+
sh ci/run.sh;
7579
fi
80+
# Check the formatting last because test failures are more interesting to have
81+
# discovered for contributors lacking some platform access for testing beforehand
7682
- if [ "${TARGET}" = x86_64-unknown-linux-gnu ]; then
7783
shellcheck -s dash -e SC1090 -- rustup-init.sh ci/*.sh;
84+
cargo fmt --all -- --check;
7885
fi
7986

87+
# Random attempt at debugging currently. Just poking around in here to see if
88+
# anything shows up.
89+
after_failure:
90+
# Dump backtrace for macOS
91+
- ls -lat "$HOME"/Library/Logs/DiagnosticReports/
92+
- find "$HOME"/Library/Logs/DiagnosticReports
93+
-type f
94+
-name '*.crash'
95+
-not -name '*.stage2-*.crash'
96+
-not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash'
97+
-exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \;
98+
-exec head -750 {} \;
99+
-exec echo travis_fold":"end:crashlog \; || true
100+
101+
# Dump backtrace for Linux
102+
- ln -s . checkout &&
103+
for CORE in obj/cores/core.*; do
104+
EXE=$(echo $CORE | sed 's@obj/cores/core\.[0-9]*\.!checkout!\(.*\)@\1@;y@!@/@');
105+
if [ -f "$EXE" ]; then
106+
printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE";
107+
gdb --batch -q -c "$CORE" "$EXE"
108+
-iex 'set auto-load off'
109+
-iex 'dir src/'
110+
-iex 'set sysroot .'
111+
-ex bt
112+
-ex q;
113+
echo travis_fold":"end:crashlog;
114+
fi;
115+
done || true
116+
80117
before_deploy:
81118
- sh ci/prepare-deploy-travis.sh
82119

ci/build-run-docker.sh

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
#!/bin/bash
22

3-
script_dir=$(cd "$(dirname "$0")" && pwd)
3+
root_dir="$TRAVIS_BUILD_DIR"
4+
script_dir="$root_dir/ci"
5+
objdir="$root_dir"/obj
6+
47
. "$script_dir/shared.sh"
58

69
set -e
710
# Disable cause it makes shared script not to work properly
811
#set -x
912

10-
mkdir -p target
13+
mkdir -p "$HOME"/.cargo
14+
mkdir -p "$objdir"/cores
15+
mkdir -p "$HOME"/.cache/sccache
16+
17+
# Enable core dump on Linux
18+
sudo sh -c 'echo "/checkout/obj/cores/core.%p.%E" > /proc/sys/kernel/core_pattern';
1119

1220
DOCKER="$1"
1321
TARGET="$2"
@@ -27,23 +35,34 @@ if [ -f "ci/docker/$DOCKER/Dockerfile" ]; then
2735
travis_fold end "build.Dockerfile.${DOCKER}"
2836
fi
2937

38+
# Run containers as privileged as it should give them access to some more
39+
# syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was
40+
# discovered that the leak sanitizer apparently needs these syscalls nowadays so
41+
# we'll need `--privileged` for at least the `x86_64-gnu` builder, so this just
42+
# goes ahead and sets it for all builders.
3043
# shellcheck disable=SC2016
3144
docker run \
32-
--entrypoint sh \
45+
--entrypoint /bin/sh \
3346
--user "$(id -u)":"$(id -g)" \
34-
--volume "$(rustc --print sysroot)":/travis-rust:ro \
35-
--volume "$(pwd)":/src:ro \
36-
--volume "$(pwd)"/target:/src/target \
37-
--workdir /src \
47+
--volume "$(rustc --print sysroot)":/rustc-sysroot:ro \
48+
--volume "$root_dir":/checkout:ro \
49+
--volume "$root_dir"/target:/checkout/target \
50+
--volume "$objdir":/checkout/obj \
51+
--workdir /checkout \
52+
--privileged \
3853
--env TARGET="$TARGET" \
3954
--env SKIP_TESTS="$SKIP_TESTS" \
40-
--env CARGO_HOME=/src/target/cargo-home \
41-
--env CARGO_TARGET_DIR=/src/target \
55+
--volume "$HOME/.cargo:/cargo" \
56+
--env CARGO_HOME=/cargo \
57+
--env CARGO_TARGET_DIR=/checkout/target \
4258
--env LIBZ_SYS_STATIC=1 \
59+
--volume "$HOME"/.cache/sccache:/sccache \
60+
--env SCCACHE_DIR=/sccache \
4361
--tty \
4462
--init \
63+
--rm \
4564
"$DOCKER" \
46-
-c 'PATH="$PATH":/travis-rust/bin exec sh ci/run.sh'
65+
-c 'PATH="$PATH":/rustc-sysroot/bin sh ci/run.sh'
4766

4867
# check that rustup-init was built with ssl support
4968
# see https://github.com/rust-lang/rustup.rs/issues/1051

ci/fetch-rust-docker.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22

3-
script_dir=$(cd "$(dirname "$0")" && pwd)
3+
root_dir="$TRAVIS_BUILD_DIR"
4+
script_dir="$root_dir/ci"
5+
46
. "$script_dir/shared.sh"
57

68
set -e

ci/run.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
set -ex
44

5+
# only enable core dump on Linux
6+
if [ -f /proc/sys/kernel/core_pattern ]; then
7+
# shellcheck disable=SC2169
8+
# `-c` exists in Ubuntu 14.04 and later at least
9+
ulimit -c unlimited
10+
fi
11+
512
rustc -vV
613
cargo -vV
714
rustfmt -vV
@@ -12,7 +19,3 @@ if [ -z "$SKIP_TESTS" ]; then
1219
cargo test --release -p download --target "$TARGET" --features vendored-openssl
1320
cargo test --release --target "$TARGET" --features vendored-openssl
1421
fi
15-
16-
# Check the formatting last because test failures are more interesting to have
17-
# discovered for contributors lacking some platform access for testing beforehand
18-
cargo fmt --all -- --check

0 commit comments

Comments
 (0)