Skip to content

Conversation

@lrineau
Copy link
Member

@lrineau lrineau commented Oct 31, 2025

Summary

This PR adds a new debugging utility bisect_failures to the STL_Extension package. This function helps identify minimal failing test cases from complex input data by using a bisection-like approach.

Small feature: bisect failures debugging utility

Features

  • Multiple failure type support: Handles CGAL exceptions, std::exceptions, and exit codes
  • Automatic granularity adjustment: Starts with ratio=0.5, automatically halves when no fault is found
  • Debug output: Saves intermediate states (current, bad, error, final_bad)
  • Template-based design: Works with any copyable/assignable data type

Testing

Added comprehensive test suite (test_bisect_failures.cpp) with 14 tests:

  • ✅ Edge cases (empty data, no failures)
  • ✅ Single element failures (CGAL exception, std::exception, exit code)
  • ✅ Pair combinations (all 2-element permutations)
  • ✅ Triple combinations (all 3 failure types together)

All tests pass in both Debug and Release configurations.

Use Case

This utility is particularly useful for:

  • Debugging complex geometric algorithms with large input datasets
  • Finding minimal reproducible test cases from failing inputs
  • Isolating problematic elements in mesh processing, triangulation, etc.

Example Usage

auto get_size = [](const Mesh& m) { return m.number_of_faces(); };
auto simplify = [](Mesh& m, std::size_t start, std::size_t end) -> bool {
  // Remove faces from start to end
  for(std::size_t i = start; i < end && i < m.number_of_faces(); ++i) {
    m.remove_face(start);
  }
  return true;
};
auto run = [](const Mesh& m) -> int { return algorithm(m); };
auto save = [](const Mesh& m, const std::string& prefix) {
  std::ofstream out(prefix + ".off");
  out << m;
};

int result = bisect_failures(mesh, get_size, simplify, run, save);

Files Changed

  • STL_Extension/include/CGAL/bisect_failures.h (new) - Main utility header
  • STL_Extension/test/STL_Extension/test_bisect_failures.cpp (new) - Test suite
  • STL_Extension/test/STL_Extension/CMakeLists.txt (modified) - Added test

Checklist

  • Code compiles without errors (Debug and Release)
  • All tests pass
  • Comprehensive documentation with Doxygen comments
  • Example usage in documentation
  • Follows CGAL coding style conventions
  • Deal with false positive in the testsuite

Release Management

  • Affected package(s): STL_Extension
  • Feature/Small Feature (if any): bisect failures debugging utility
  • Link to compiled documentation (obligatory for small feature) doc
  • License and copyright ownership: no change

Add new bisect_failures template function to help identify minimal failing
test cases from complex input data. The utility uses a bisection-like approach
to iteratively simplify data and locate the smallest subset that causes failures.

Features:
- Handles multiple failure types: CGAL exceptions, std::exceptions, exit codes
- Automatic ratio adjustment (starts at 0.5, halves when no fault found)
- Saves intermediate states for debugging (current, bad, error, final_bad)
- Comprehensive test suite with 14 tests covering all combinations:
  * Edge cases (empty data, no failures)
  * Single element failures (each failure type independently)
  * Pair combinations (all 2-element permutations)
  * Triple combinations (all 3 failure types together)
  * Large datasets (up to 200 elements)

The test suite demonstrates complete combinatorial coverage of three
independent failure conditions and validates the algorithm's ability to
isolate minimal failing cases.

All tests pass in both Debug and Release configurations.
@lrineau lrineau marked this pull request as draft October 31, 2025 15:02
@lrineau

This comment was marked as outdated.

@lrineau lrineau added Enhancement Pkg::STL_Extension Not yet approved The feature or pull-request has not yet been approved. Small feature and removed Enhancement labels Oct 31, 2025
@lrineau lrineau added this to the 6.2-beta milestone Oct 31, 2025
@github-actions

This comment was marked as outdated.

@lrineau

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@afabri afabri added the TODO label Nov 7, 2025
@lrineau lrineau marked this pull request as ready for review November 12, 2025 13:58
@lrineau

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@lrineau

This comment was marked as outdated.

@lrineau lrineau requested review from afabri and sloriot January 21, 2026 15:48
@afabri
Copy link
Member

afabri commented Jan 21, 2026

/force-build:v0

@github-actions
Copy link

The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/9118/v0/Manual/index.html

@lrineau
Copy link
Member Author

lrineau commented Jan 22, 2026

Seems to fail with ICPC. See here

ICPC version is 2025.1 on Christo, whereas the latest version is 2025.3. Maybe we should upgrade.

That will ensure that the `clog` buffer is flushed before any output to `cerr`.
@lrineau
Copy link
Member Author

lrineau commented Jan 22, 2026

/build:v2

@github-actions
Copy link

The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/9118/v2/Manual/index.html

@lrineau
Copy link
Member Author

lrineau commented Jan 22, 2026

@afabri @sloriot Please re-review: CGAL bisect_failures v2.

Copy link
Member

@sloriot sloriot left a comment

Choose a reason for hiding this comment

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

I like this version better! Still some occurrences of minimal and smallest remaining that I'd prefer being replaced with reduced for example.

Copy link
Member

@afabri afabri left a comment

Choose a reason for hiding this comment

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

I made suggestions for replacing minimal @lrineau

Copy link
Member Author

@lrineau lrineau left a comment

Choose a reason for hiding this comment

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

I have applied all of your suggestions in the last commit.

@afabri afabri added pre-approved For pre-approved small features. After 15 days the feature will be accepted. and removed Not yet approved The feature or pull-request has not yet been approved. labels Jan 26, 2026
@lrineau
Copy link
Member Author

lrineau commented Jan 26, 2026

/build:v3

@github-actions
Copy link

The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/9118/v3/Manual/index.html

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

Labels

Pkg::STL_Extension pre-approved For pre-approved small features. After 15 days the feature will be accepted. Ready to be tested Small feature Under Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants