Skip to content

debug: py3.13 GHA build-with-clang segfault #193

debug: py3.13 GHA build-with-clang segfault

debug: py3.13 GHA build-with-clang segfault #193

name: Build project with IntelLLVM clang compiler
on:
pull_request:
push:
branches: [master]
permissions: read-all
jobs:
build-with-clang:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13"]
numpy_version: ["numpy'>=2'"]
env:
ONEAPI_ROOT: /opt/intel/oneapi
defaults:
run:
shell: bash -el {0}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1
with:
access_token: ${{ github.token }}
- name: Add Intel repository
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
sudo apt-get update
- name: Install Intel OneAPI
run: |
sudo apt-get install intel-oneapi-compiler-dpcpp-cpp
sudo apt-get install intel-oneapi-tbb
sudo apt-get install intel-oneapi-mkl-devel
- name: Setup Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Checkout repo
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Install mkl_umath dependencies
run: |
pip install scikit-build cmake ninja cython setuptools">=77"
pip install ${{ matrix.numpy_version }}
- name: List oneAPI folder content
run: ls ${{ env.ONEAPI_ROOT }}/compiler
- name: Install gdb
run: |
sudo apt-get update --fix-missing
sudo apt-get install -y gdb
- name: Build mkl_umath
run: |
source ${{ env.ONEAPI_ROOT }}/setvars.sh
echo $CMPLR_ROOT
export CC=$CMPLR_ROOT/bin/icx
export CFLAGS="${CFLAGS} -g -fno-fast-math -O0"
pip install . --no-build-isolation --no-deps --verbose
- name: Run tests under gdb
run: |
source ${{ env.ONEAPI_ROOT }}/setvars.sh
pip install pytest
cd ..
setarch $(uname -m) -R gdb --batch -ex r -ex 'info sharedlibrary' -ex 'set print elements 1000' -ex bt --args python -m pytest -s -v --pyargs mkl_umath/mkl_umath/tests || true
- name: run tests under valgrind
run: |
sudo apt-get install -y valgrind
source ${{ env.ONEAPI_ROOT }}/setvars.sh
pip install pytest
cd ..
valgrind --error-exitcode=99 python -m pytest -s -v --pyargs mkl_umath/mkl_umath/tests || true
- name: Run mkl_umath tests
run: |
source ${{ env.ONEAPI_ROOT }}/setvars.sh
ulimit -c unlimited
pip install pytest
cd ..
# First a minimal import to see if pure import crashes
python -X faulthandler -c "import numpy, mkl_umath; print('import-only OK')"
# Run tests normally; expect segfault
python -X faulthandler -m pytest -q --pyargs mkl_umath/mkl_umath/tests || echo "pytest exit code=$?"
COREFILE=$(ls core* 2>/dev/null | head -1 || true)
if [ -f "$COREFILE" ]; then
echo "Core file: $COREFILE"
gdb -batch -ex "bt full" -ex "info threads" python "$COREFILE"
else
echo "No core produced"
fi
# Retry with MKL mitigations to confirm cause
export MKL_DISABLE_FAST_MM=1
export MKL_THREADING_LAYER=SEQUENTIAL
python -X faulthandler -c "import numpy, mkl_umath; print('sequential + fast_mm disabled import OK')"
python -X faulthandler -m pytest -q --pyargs mkl_umath/mkl_umath/tests || echo "pytest (sequential) exit code=$?"
# Show loaded modules
python - <<'EOF'
import sys, mkl_umath, numpy
print("Loaded mkl_umath from:", mkl_umath.__file__)
print("MKL_THREADING_LAYER =", __import__('os').environ.get('MKL_THREADING_LAYER'))
print("Has _ufuncs:", '_ufuncs' in dir(mkl_umath))
EOF