Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 2, 2025

GitHub Actions workflow crashes with free(): invalid next size (fast) (exit code 134) after all 974 tests pass. This is heap corruption during Numba JIT cleanup at process exit, not a test failure.

Changes

  • Added NUMBA_DISABLE_CACHING: 1 env var to test and benchmark jobs in .github/workflows/test.yml
jobs:
  test:
    env:
      NUMBA_DISABLE_CACHING: 1

This prevents Numba from writing/reading cache files that trigger the memory corruption during pytest teardown.

Original prompt

Issue

The GitHub Actions workflow is crashing with a memory corruption error after all 974 tests pass successfully. This is a Numba-related cleanup issue, not a test failure.

Error Log

============================= 974 passed in 37.63s =============================
free(): invalid next size (fast)
/home/runner/work/_temp/3c174abc-164c-4411-9d04-9a0ada0106de.sh: line 1:  2210 Aborted (core dumped)
##[error]Process completed with exit code 134.

Key Observations

  • ✅ All 974 tests pass successfully
  • ❌ Process crashes during pytest cleanup/teardown with exit code 134 (SIGABRT)
  • The error free(): invalid next size (fast) indicates heap corruption
  • This is caused by Numba JIT-compiled functions corrupting memory during process exit

Required Fix

Option 1: Modify GitHub Actions Workflow (.github/workflows/test.yml)

  1. Set environment variables to prevent Numba caching issues:

    env:
      NUMBA_DISABLE_CACHING: 1
      NUMBA_CACHE_DIR: /tmp/numba_cache
  2. OR use set +e to continue even if pytest exits with non-zero code, then check if tests actually passed:

    - name: Run tests
      run: |
        set +e
        pytest -v --ignore=tests/accuracy --ignore=tests/benchmark -x 2>&1 | tee test_output.txt
        exit_code=$?
        if grep -q "passed" test_output.txt && ! grep -q "failed" test_output.txt; then
          echo "All tests passed (ignoring cleanup crash)"
          exit 0
        fi
        exit $exit_code

Option 2: Add pytest configuration to handle cleanup gracefully

  1. Add to pyproject.toml or pytest.ini:

    [tool.pytest.ini_options]
    addopts = "-p no:cacheprovider"
  2. Or use conftest.py to add cleanup handling:

    import atexit
    import gc
    
    def cleanup():
        gc.collect()
    
    atexit.register(cleanup)

Option 3: Disable Numba JIT for unit tests (recommended for CI stability)

In the workflow, set:

env:
  NUMBA_DISABLE_JIT: 1

This makes unit tests run without JIT compilation (slower but stable). Keep a separate job for performance tests with JIT enabled.

Files to Modify

  • .github/workflows/test.yml - Primary fix location
  • Optionally tests/conftest.py - Add cleanup handlers
  • Optionally pyproject.toml - Add pytest configuration

Acceptance Criteria

  • All 974 tests still pass
  • GitHub Actions workflow completes with exit code 0
  • No segfaults or memory corruption errors
  • Solution is robust and doesn't mask actual test failures

This pull request was created as a result of the following prompt from Copilot chat.

Issue

The GitHub Actions workflow is crashing with a memory corruption error after all 974 tests pass successfully. This is a Numba-related cleanup issue, not a test failure.

Error Log

============================= 974 passed in 37.63s =============================
free(): invalid next size (fast)
/home/runner/work/_temp/3c174abc-164c-4411-9d04-9a0ada0106de.sh: line 1:  2210 Aborted (core dumped)
##[error]Process completed with exit code 134.

Key Observations

  • ✅ All 974 tests pass successfully
  • ❌ Process crashes during pytest cleanup/teardown with exit code 134 (SIGABRT)
  • The error free(): invalid next size (fast) indicates heap corruption
  • This is caused by Numba JIT-compiled functions corrupting memory during process exit

Required Fix

Option 1: Modify GitHub Actions Workflow (.github/workflows/test.yml)

  1. Set environment variables to prevent Numba caching issues:

    env:
      NUMBA_DISABLE_CACHING: 1
      NUMBA_CACHE_DIR: /tmp/numba_cache
  2. OR use set +e to continue even if pytest exits with non-zero code, then check if tests actually passed:

    - name: Run tests
      run: |
        set +e
        pytest -v --ignore=tests/accuracy --ignore=tests/benchmark -x 2>&1 | tee test_output.txt
        exit_code=$?
        if grep -q "passed" test_output.txt && ! grep -q "failed" test_output.txt; then
          echo "All tests passed (ignoring cleanup crash)"
          exit 0
        fi
        exit $exit_code

Option 2: Add pytest configuration to handle cleanup gracefully

  1. Add to pyproject.toml or pytest.ini:

    [tool.pytest.ini_options]
    addopts = "-p no:cacheprovider"
  2. Or use conftest.py to add cleanup handling:

    import atexit
    import gc
    
    def cleanup():
        gc.collect()
    
    atexit.register(cleanup)

Option 3: Disable Numba JIT for unit tests (recommended for CI stability)

In the workflow, set:

env:
  NUMBA_DISABLE_JIT: 1

This makes unit tests run without JIT compilation (slower but stable). Keep a separate job for performance tests with JIT enabled.

Files to Modify

  • .github/workflows/test.yml - Primary fix location
  • Optionally tests/conftest.py - Add cleanup handlers
  • Optionally pyproject.toml - Add pytest configuration

Acceptance Criteria

  • All 974 tests still pass
  • GitHub Actions workflow completes with exit code 0
  • No segfaults or memory corruption errors
  • Solution is robust and doesn't mask actual test failures

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: deepentropy <8287111+deepentropy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Numba-related memory corruption in GitHub Actions Fix Numba memory corruption in CI by disabling caching Dec 2, 2025
Copilot AI requested a review from deepentropy December 2, 2025 12:17
@deepentropy deepentropy marked this pull request as ready for review December 2, 2025 12:30
Copilot AI review requested due to automatic review settings December 2, 2025 12:30
@deepentropy deepentropy merged commit 443be84 into main Dec 2, 2025
4 of 14 checks passed
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@deepentropy deepentropy deleted the copilot/fix-numba-cache-issue branch December 2, 2025 12:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Numba-related heap corruption issue that was causing GitHub Actions workflows to crash with exit code 134 after successfully passing all 974 tests. The solution disables Numba's caching mechanism which was triggering memory corruption during process cleanup.

Key Changes:

  • Added NUMBA_DISABLE_CACHING: 1 environment variable to prevent Numba from writing/reading cache files
  • Applied to both test and benchmark jobs to ensure consistent behavior across all test runs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants