Skip to content

CI: Enable core dump on Linux #1802

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

Closed
wants to merge 2 commits into from
Closed
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
52 changes: 44 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
dist: xenial
services:
- docker
language: generic
language: minimal
addons:
apt:
packages:
- gdb

git:
depth: false
Expand Down Expand Up @@ -55,29 +59,61 @@ matrix:
env: MACOSX_DEPLOYMENT_TARGET=10.7 TARGET=i686-apple-darwin

install:
- sh rustup-init.sh --default-toolchain=stable -y
- export PATH="$PATH:$HOME/.cargo/bin"
- sh ./rustup-init.sh --default-toolchain=stable -y
- . "$HOME/.cargo/env"
- if [ -z "$NO_ADD" ]; then rustup target add "$TARGET"; fi
- rustup component add rustfmt

script:
- mkdir -p target/"$TARGET";
- >
case "$TARGET" in
*-linux-android) DOCKER=android ;; # Android uses a local docker image
*-linux-androideabi) DOCKER=android ;;
*-apple-darwin) ;;
*) DOCKER=$TARGET ;;
*-linux-android*) DOCKER=android ;; # Android uses a local docker image
*-apple-darwin) ;;
*) DOCKER="$TARGET";;
esac;
if [ -n "$DOCKER" ]; then
sh ci/build-run-docker.sh "$DOCKER" "$TARGET" "$SKIP_TESTS";
else
PATH="$HOME/rust/bin:$PATH" sh ci/run.sh;
sh ci/run.sh;
fi
# Check the formatting last because test failures are more interesting to have
# discovered for contributors lacking some platform access for testing beforehand
- if [ "${TARGET}" = x86_64-unknown-linux-gnu ]; then
shellcheck -s dash -e SC1090 -- rustup-init.sh ci/*.sh;
cargo fmt --all -- --check;
fi

# Random attempt at debugging currently. Just poking around in here to see if
# anything shows up.
after_failure:
# Dump backtrace for macOS
- ls -lat "$HOME"/Library/Logs/DiagnosticReports/
- find "$HOME"/Library/Logs/DiagnosticReports
-type f
-name '*.crash'
-not -name '*.stage2-*.crash'
-not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash'
-exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \;
-exec head -750 {} \;
-exec echo travis_fold":"end:crashlog \; || true

# Dump backtrace for Linux
- ln -s . checkout &&
for CORE in obj/cores/core.*; do
EXE=$(echo $CORE | sed 's@obj/cores/core\.[0-9]*\.!checkout!\(.*\)@\1@;y@!@/@');
if [ -f "$EXE" ]; then
printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE";
gdb --batch -q -c "$CORE" "$EXE"
-iex 'set auto-load off'
-iex 'dir src/'
-iex 'set sysroot .'
-ex bt
-ex q;
echo travis_fold":"end:crashlog;
fi;
done || true

before_deploy:
- sh ci/prepare-deploy-travis.sh

Expand Down
39 changes: 29 additions & 10 deletions ci/build-run-docker.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/bin/bash

script_dir=$(cd "$(dirname "$0")" && pwd)
root_dir="$TRAVIS_BUILD_DIR"
script_dir="$root_dir/ci"
objdir="$root_dir"/obj

. "$script_dir/shared.sh"

set -e
# Disable cause it makes shared script not to work properly
#set -x

mkdir -p target
mkdir -p "$HOME"/.cargo
mkdir -p "$objdir"/cores
mkdir -p "$HOME"/.cache/sccache

# Enable core dump on Linux
sudo sh -c 'echo "/checkout/obj/cores/core.%p.%E" > /proc/sys/kernel/core_pattern';

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

# Run containers as privileged as it should give them access to some more
# syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was
# discovered that the leak sanitizer apparently needs these syscalls nowadays so
# we'll need `--privileged` for at least the `x86_64-gnu` builder, so this just
# goes ahead and sets it for all builders.
# shellcheck disable=SC2016
docker run \
--entrypoint sh \
--entrypoint /bin/sh \
--user "$(id -u)":"$(id -g)" \
--volume "$(rustc --print sysroot)":/travis-rust:ro \
--volume "$(pwd)":/src:ro \
--volume "$(pwd)"/target:/src/target \
--workdir /src \
--volume "$(rustc --print sysroot)":/rustc-sysroot:ro \
--volume "$root_dir":/checkout:ro \
--volume "$root_dir"/target:/checkout/target \
--volume "$objdir":/checkout/obj \
--workdir /checkout \
--privileged \
--env TARGET="$TARGET" \
--env SKIP_TESTS="$SKIP_TESTS" \
--env CARGO_HOME=/src/target/cargo-home \
--env CARGO_TARGET_DIR=/src/target \
--volume "$HOME/.cargo:/cargo" \
--env CARGO_HOME=/cargo \
--env CARGO_TARGET_DIR=/checkout/target \
--env LIBZ_SYS_STATIC=1 \
--volume "$HOME"/.cache/sccache:/sccache \
--env SCCACHE_DIR=/sccache \
--tty \
--init \
--rm \
"$DOCKER" \
-c 'PATH="$PATH":/travis-rust/bin exec sh ci/run.sh'
-c 'PATH="$PATH":/rustc-sysroot/bin sh ci/run.sh'

# check that rustup-init was built with ssl support
# see https://github.com/rust-lang/rustup.rs/issues/1051
Expand Down
4 changes: 3 additions & 1 deletion ci/fetch-rust-docker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

script_dir=$(cd "$(dirname "$0")" && pwd)
root_dir="$TRAVIS_BUILD_DIR"
script_dir="$root_dir/ci"

. "$script_dir/shared.sh"

set -e
Expand Down
11 changes: 7 additions & 4 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

set -ex

# only enable core dump on Linux
if [ -f /proc/sys/kernel/core_pattern ]; then
# shellcheck disable=SC2169
# `-c` exists in Ubuntu 14.04 and later at least
ulimit -c unlimited
fi

rustc -vV
cargo -vV
rustfmt -vV
Expand All @@ -12,7 +19,3 @@ if [ -z "$SKIP_TESTS" ]; then
cargo test --release -p download --target "$TARGET" --features vendored-openssl
cargo test --release --target "$TARGET" --features vendored-openssl
fi

# Check the formatting last because test failures are more interesting to have
# discovered for contributors lacking some platform access for testing beforehand
cargo fmt --all -- --check