java-topology/whitepaper/outreach/solvespace-0001.md
russell@unturf.com 652608142a feat: close outreach doc gap — 276 docs (batches 11-16)
All projects with patches now have outreach docs. 276 new docs covering
CWE-407, CWE-312, CWE-362 across C, C++, Java, Python, Go, Rust, C#,
PHP, Ruby, JavaScript, Dart, Erlang, R, and more.

Outreach gap: 276 -> 0.
2026-04-15 13:57:42 -04:00

2.2 KiB
Raw Permalink Blame History

SolveSpace — CWE-407 Disclosure Brief (solvespace-0001)

2026-04-13 · Patch available — awaiting upstream merge

Finding

An O(A×C) linear scan in ARC_OF_CIRCLE equation generation at src/entity.cpp:938. For each arc entity, std::find_if() scans all constraints in the sketch to find POINTS_COINCIDENT constraints matching the arc's endpoints. With A arcs and C constraints, total cost reaches O(A×C) per GenerateEquations() call.

The Defect

solvespace-0001 (PATCHED — MEDIUM): src/entity.cpp

case Type::ARC_OF_CIRCLE: {
    auto it = std::find_if(SK.constraint.begin(), SK.constraint.end(),
        [&](ConstraintBase const &con) {
            return (con.group == group) &&
                   (con.type == Constraint::Type::POINTS_COINCIDENT) &&
                   ((con.ptA == point[1] && con.ptB == point[2]) ||
                    (con.ptA == point[2] && con.ptB == point[1]));
        });  // O(C) per arc

Complexity Proof

At A=100 arcs, C=500 constraints:

  • Defective: 100 × 500 = 50,000 comparisons
  • Fixed: C constraint scan once (500) + 100 × O(1) lookups = 600
  • 83× op reduction

Impact

SolveSpace serves engineers and makers for parametric 2D/3D CAD. Equation generation fires on every constraint solve cycle (every edit, drag, or dimension change). Sketches with many arcs and constraints trigger visible solver lag.

The Fix

Build a thread_local std::unordered_set<uint64_t> cache of coincident endpoint pairs for each group. The cache populates on first arc encountered per group, then provides O(1) lookups for subsequent arcs:

uint64_t key = ((uint64_t)point[1].v << 32) | point[2].v;
if(coincidentCache.count(key)) { break; }

Patch

Fix available: defects/solvespace-0001/patch/solvespace-0001-arc-constraint-scan.patch

83× op reduction at A=100, C=500.

What We Ask

  1. Confirm receipt and assign a GitHub issue reference (solvespace/solvespace).
  2. Assess severity — fires on every constraint solve cycle.
  3. Coordinate a disclosure date — targeting 90 days from first contact.
  4. We will credit the SolveSpace team in the public disclosure.

Contact: see cover email. This brief is confidential until coordinated disclosure.