Skip to content

Address the review on OCCT#1417 and re-cut carried patch 0018 to match #755

Description

@gsdali

OCCT#1417 is our upstream filing of carried
patch 0018 (#555, GCPnts degenerate count and duplicate end point). Maintainer gkv311
reviewed it on 2026-08-03
with three requested changes. It has been sitting unanswered since.

The three are not cosmetic in equal measure: the first is a design decision that lands differently
in our build than in a stock one, and it needs deciding rather than picking whichever wording is
shorter.

The three requests

1. The No_Exception duplicate guard, which is the real one

We wrote, in both GCPnts_QuasiUniformAbscissa::initialize and GCPnts_UniformAbscissa::initialize:

Standard_ConstructionError_Raise_if(theNbPoints <= 1, "...");
if (theNbPoints <= 1)
{
  // The check above is compiled out in a build defining No_Exception.
  myDone = false; myNbPoints = 0; return;
}

gkv311's objection is that *_Raise_if is an assert-grade macro, deliberately compiled out in
release for overhead, and that duplicating it is the wrong shape. He offers two fixes:

  • (a) replace the macro with an unconditional if (...) throw Standard_ConstructionError(...);
  • (b) "remove this duplicating check and keep only myDone=false;"

Read (b) carefully before implementing it. Taken literally in QuasiUniformAbscissa it is a
regression: deleting the block removes the return as well, and execution falls through into the
store to myParams, which is allocated empty for that count. That store is the entire defect #555
reported. What (b) has to mean is replace the _Raise_if with { myDone = false; myNbPoints = 0; return; }, not delete anything. Note that UniformAbscissa's site already assigns both fields
above the guard, so only the early return is load-bearing there, which is exactly the kind of
asymmetry that makes a one-line review instruction ambiguous.

Why the choice is ours to make and not a coin flip. We build with
BUILD_RELEASE_DISABLE_EXCEPTIONS=ON, which defines No_Exception, so today the macro is gone in
our kernel and the guard we added is the only thing standing there. Under (a) a degenerate count
starts throwing in our build, where it currently cannot; under (b) it stays a silent not-done.

Measure before choosing, do not reason it out:

If both options preserve our observable contract, prefer (b): it keeps the degenerate case a
not-done result rather than an exception, which is what #555 argued for, and it is the option that
does not depend on whether the consumer defines No_Exception. Say so in the reply, with the
measurement, rather than just complying.

2. Distance() in a loop

|| (aUU2 - aUi < aDelta && theC.Value(aUi).Distance(aPEnd) <= theTol3d)

OCCT convention is SquareDistance() against a tolerance squared once outside the loop. Mechanical,
but hoist the aTol2 computation properly rather than squaring inline each iteration.

3. theTol3d is misleading

The Perform template also instantiates on Adaptor2d_Curve2d, so the name asserts something false
for half its uses. Rename to theTol. Check for shadowing against the enclosing initialize's own
theTol at the call sites.

Scope

  1. Update Scripts/patches/0018-GCPnts-degenerate-count-and-duplicate-end-point-555.patch to the
    revised form. This is the artifact of record; the upstream PR is downstream of it.
  2. Re-verify against a rebuilt or override-linked kernel, not by reading the diff. GCPnts_UniformAbscissa/QuasiUniformAbscissa: two unpatched kernel defects behind #501's buffer-overflow fix (unbounded NbPoints(), degenerate-count SIGSEGV) #555's own
    note applies: override TUs for these files need -DNo_Exception to reproduce the build the
    patch is written for, and without it you will measure the wrong branch.
  3. Re-run Scripts/repro/555-gcpnts-count-contract and confirm its verdict is unchanged. If the
    verdict moves, the review has changed behaviour and that is the finding, not a detail.
  4. Run the GCPnts_UniformAbscissa/QuasiUniformAbscissa: two unpatched kernel defects behind #501's buffer-overflow fix (unbounded NbPoints(), degenerate-count SIGSEGV) #555 suites in the Swift tests. A degenerate count must still produce the same result it
    produces today.
  5. Update Scripts/patches/README.md's 0018 section if the rationale changed.
  6. Prepare the exact commit for gsdali/OCCT's fix/555-gcpnts-point-count branch as a patch file
    under the repro dir, with the reply to gkv311 drafted alongside it.

Do not push to gsdali/OCCT or comment on OCCT#1417. Both are outward-facing and need
authorisation. Prepare them and stop.

Not in scope

Changing what the fix does. The reviewer accepted the substance and asked about form; the two
degenerate-count contracts and the duplicate-end-point suppression stay as they are.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cluster:kernelOCCTSwift core geometry/meshing/IO librariesphase:1bPass 1b — C++ bridge header duplication audit (#381)type:choreMaintenance / tooling

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions