diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 59e9b785bc..7b4f6ebc1e 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -92,6 +92,82 @@ jobs: --output-on-failure \ 2>&1 | tee logfile2 + - name: Check log for Errors + working-directory: ${{runner.workspace}}/build + shell: bash + run: | + cat logfile2 + OUTPUT='ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)' + if grep -q "$OUTPUT" logfile2; then + exit 0 + fi + exit 1 + + examples: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v4 + + - name: Install Valgrind + run: sudo apt-get update && sudo apt-get install valgrind + + - name: Create Build Environment + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Configure CMake All + shell: bash + working-directory: ${{runner.workspace}}/build + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug + + - name: Build All + working-directory: ${{runner.workspace}}/build + shell: bash + run: | + cmake --build . --parallel + + - name: Test cpp example + working-directory: ${{runner.workspace}}/build + shell: bash + run: | + valgrind \ + --leak-check=full \ + --show-leak-kinds=all \ + --track-origins=yes \ + -s \ + ./bin/call_highs_from_cpp \ + --timeout 1000 \ + --output-on-failure \ + 2>&1 | tee logfile2 + + - name: Check log for Errors + working-directory: ${{runner.workspace}}/build + shell: bash + run: | + cat logfile2 + OUTPUT='ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)' + if grep -q "$OUTPUT" logfile2; then + exit 0 + fi + exit 1 + + - name: Test C example + working-directory: ${{runner.workspace}}/build + shell: bash + run: | + valgrind \ + --leak-check=full \ + --show-leak-kinds=all \ + --track-origins=yes \ + -s \ + ./bin/call_highs_from_c_minimal \ + --timeout 1000 \ + --output-on-failure \ + 2>&1 | tee logfile2 + - name: Check log for Errors working-directory: ${{runner.workspace}}/build shell: bash diff --git a/examples/call_highs_from_cpp.cpp b/examples/call_highs_from_cpp.cpp index 530c111f08..1cabee8914 100644 --- a/examples/call_highs_from_cpp.cpp +++ b/examples/call_highs_from_cpp.cpp @@ -172,5 +172,7 @@ int main() { cout << endl; } + highs.resetGlobalScheduler(true); + return 0; } diff --git a/highs/interfaces/highs_c_api.cpp b/highs/interfaces/highs_c_api.cpp index 3f3874a579..cf5350ae48 100644 --- a/highs/interfaces/highs_c_api.cpp +++ b/highs/interfaces/highs_c_api.cpp @@ -61,6 +61,9 @@ HighsInt Highs_lpCall(const HighsInt num_col, const HighsInt num_row, if (copy_row_basis) row_basis_status[i] = (HighsInt)basis.row_status[i]; } } + + highs.resetGlobalScheduler(true); + return (HighsInt)status; } @@ -104,6 +107,8 @@ HighsInt Highs_mipCall(const HighsInt num_col, const HighsInt num_row, } } + highs.resetGlobalScheduler(true); + return (HighsInt)status; } @@ -160,12 +165,18 @@ HighsInt Highs_qpCall( if (copy_row_basis) row_basis_status[i] = (HighsInt)basis.row_status[i]; } } + + highs.resetGlobalScheduler(true); + return (HighsInt)status; } void* Highs_create(void) { return new Highs(); } -void Highs_destroy(void* highs) { delete (Highs*)highs; } +void Highs_destroy(void* highs) { + Highs::resetGlobalScheduler(true); + delete (Highs*)highs; +} const char* Highs_version(void) { return highsVersion(); } HighsInt Highs_versionMajor(void) { return highsVersionMajor(); }