java-topology/whitepaper/outreach/openmw-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.3 KiB
Raw Permalink Blame History

OpenMW — CWE-407 Disclosure Brief (openmw-0001)

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

Finding

One O(N²) defect in OpenMW's pathgrid strongly-connected component (SCC) computation. Patched. Tarjan's SCC algorithm uses std::find() on a std::vector as a stack membership test, producing O(N²) behavior during pathgrid analysis.

The Defect

openmw-0001 (PATCHED — MEDIUM): apps/openmw/mwmechanics/pathgrid.cpp:57

// In Tarjan's SCC algorithm — fires per edge during pathgrid analysis:
std::vector<size_t> mSCCStack;
// ...
else if (std::find(mSCCStack.begin(), mSCCStack.end(), w) != mSCCStack.end())
    mSCCPoint[v].second = std::min(mSCCPoint[v].second, mSCCPoint[w].first);

mSCCStack is std::vector<size_t>. std::find() is O(S) where S = stack depth. Called for every edge in the pathgrid graph. With V vertices and E edges, total cost: O(E × V) instead of O(V + E).

Complexity Proof

At V=500 vertices, E=2,000 edges:

  • Defective: 2,000 × 250 avg = 500,000 comparisons
  • Fixed: 2,000 × O(1) unordered_set lookups = 2,000 operations
  • 250× op reduction at 500 vertices.

Impact

OpenMW is an open-source reimplementation of the Morrowind engine. The pathgrid SCC analysis runs when loading cells with pathgrids (most exterior and interior cells). Large pathgrids in cities and complex dungeons trigger quadratic stack membership tests during Tarjan's algorithm.

The Fix

Add a parallel std::unordered_set<size_t> mSCCOnStack for O(1) membership:

// Before
std::find(mSCCStack.begin(), mSCCStack.end(), w) != mSCCStack.end()  // O(S)

// After
mSCCOnStack.count(w)  // O(1)
// Maintained in sync: insert on push, erase on pop

Patch

Fix available: defects/openmw-0001/patch/openmw-0001.patch

Touches apps/openmw/mwmechanics/pathgrid.cpp. 250× speedup at 500 pathgrid vertices.

What We Ask

A patch is ready for review.

  1. Confirm receipt and assign a GitLab issue reference (OpenMW/openmw).
  2. Assess severity — fires during cell loading with pathgrid analysis.
  3. Coordinate a disclosure date — we are targeting 90 days from first contact.
  4. We will credit the OpenMW team in the public disclosure. Preferred acknowledgment format welcome.

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