diff --git a/.travis.yml b/.travis.yml index 8e4f874..0a60376 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,40 +1,43 @@ -language: cpp +language: python env: matrix: - - CRASH_PLEASE=boooooooom - - HAPPY_NO_CRASH=all-good - -compiler: - # gcc compiler, clang would be fine too - - gcc + # These must match one of the lines from `python-build --definitions` + #- PYTHON=2.6.9 ## 2.6 doesn't have the gdb tools + - PYTHON=2.7.8 + - PYTHON=3.3.6 + - PYTHON=3.4.2 before_install: # install the gnu debugger for later use in reading the core file - sudo apt-get -y install gdb + # use pyenv to build a debug version of python + - sudo python-build --keep --debug $PYTHON /opt/python/${PYTHON}-dbg + # The cpython source tree has useful gdb tools that make its core dumps readable + - PYTHON_GDBTOOLS=$(ls -1rdt /tmp/python-build.*/Python-$PYTHON/Tools/gdb/ | head -1) -install: - # What is the current file size max for core files? - # It is usually 0, which means no core file will be dumped if there is a crash - - ulimit -c + + # make a virtualenv for the -dbg interpreter + - virtualenv --python /opt/python/${PYTHON}-dbg/bin/python virtualenv/python${PYTHON}-dbg + - source virtualenv/python${PYTHON}-dbg/bin/activate + - pip install virtualenv before_script: - # Set the core file limit to unlimited so a core file is generated upon crash - - ulimit -c unlimited -S + # What is the current file size max for core files? + # It is usually 0, which means no core file will be dumped if there is a crash + - ulimit -Hc # hard limit + - ulimit -Sc # soft limit + - python-build --definitions # show available pythons script: - - RESULT=0 - # Compile our demo program which will crash if - # the CRASH_PLEASE environment variable is set (to anything) - - g++ -o test might_crash.cpp -g -O0 -DDEBUG # Run the program to prompt a crash - # Note: we capture the return code of the program here and add - # `|| true` to ensure that travis continues past the crash - - RESULT=$(./test > /dev/null)$? || true - - if [[ ${RESULT} == 0 ]]; then echo "\\o/ our test worked without problems"; else echo "ruhroh test returned an errorcode of $RESULT"; fi; - # If the program returned an error code, now we check for a - # core file in the current working directory and dump the backtrace out - - for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb $(pwd)/test core* -ex "thread apply all bt" -ex "set pagination 0" -batch; done; - # now we should present travis with the original - # error code so the run cleanly stops - - if [[ ${RESULT} != 0 ]]; then exit $RESULT ; fi; + - bash -c 'ulimit -Sc unlimited && source ./repro.sh' + # Now we check for a core file and dump the backtrace out + - > + find -regex '.*/core\(\.[0-9]+\)?' | + xargs -rn1 --verbose + gdb $(which python) + -ex "python import sys; sys.path.append('$PYTHON_GDBTOOLS'); import libpython; reload(libpython)" + -ex "thread apply all py-bt" + -ex "thread apply all bt" + -batch diff --git a/might_crash.cpp b/might_crash.cpp deleted file mode 100644 index 6b48b57..0000000 --- a/might_crash.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main() { - if( getenv("CRASH_PLEASE") ) { - // this will crash - delete (int*)0xffffffff; - } -} \ No newline at end of file diff --git a/repro.sh b/repro.sh new file mode 100755 index 0000000..54f2751 --- /dev/null +++ b/repro.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -ex + +rm -rf clean +mkdir clean +cd clean/ +virtualenv tmpvenv + +./tmpvenv/bin/pip install --upgrade pip wheel coverage +./tmpvenv/bin/pip wheel coverage +./tmpvenv/bin/python -m coverage.__main__ run -m pip install --no-index --ignore-installed --find-links wheelhouse/ coverage