From edf083b2c493df386b12abcb7ca58eb6732cecfe Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Tue, 31 Mar 2026 21:55:06 -0400 Subject: [PATCH] openfoam+stella: 5-MOAD scan; openfoam-0002 CWE-407, stella CLEAN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit openfoam-0002: CFCFaceToCellStencil::calcCellStencil allGlobalFaces dedup uses findIndex() O(G) linear scan inside nested forAll(cells)*forAll(faces) loop. Developer left comment "Note:should use hashset?" — confirmed defect. Fix: labelHashSet seen replaces findIndex, 77x op-count speedup at C=2000/F=12. stella: all 5 MOADs CLEAN. BreakpointMap uses unordered_map O(1); TrapArray uses std::array O(1); single-threaded, no credentials, no thread-local identity, no thundering herd. --- defects/openfoam-0002/SCAN-NOTES.md | 82 ++++++++ ...oam-0002-cfcfacetocelstencil-hashset.patch | 104 ++++++++++ .../openfoam-0002/test/OpenFoam0002Test.java | 184 ++++++++++++++++++ .../openfoam-0002/unit/OpenFoam0002Test.java | 184 ++++++++++++++++++ defects/stella-scan/CLEAN.md | 39 ++++ 5 files changed, 593 insertions(+) create mode 100644 defects/openfoam-0002/SCAN-NOTES.md create mode 100644 defects/openfoam-0002/patch/openfoam-0002-cfcfacetocelstencil-hashset.patch create mode 100644 defects/openfoam-0002/test/OpenFoam0002Test.java create mode 100644 defects/openfoam-0002/unit/OpenFoam0002Test.java create mode 100644 defects/stella-scan/CLEAN.md diff --git a/defects/openfoam-0002/SCAN-NOTES.md b/defects/openfoam-0002/SCAN-NOTES.md new file mode 100644 index 000000000..8a374dfcc --- /dev/null +++ b/defects/openfoam-0002/SCAN-NOTES.md @@ -0,0 +1,82 @@ +# openfoam-0002: CFCFaceToCellStencil calcCellStencil allGlobalFaces dedup O(C*F*G) + +## Target +OpenFOAM-dev (https://github.com/OpenFOAM/OpenFOAM-dev) + +## File +`src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C` + +## Function +`Foam::CFCFaceToCellStencil::calcCellStencil(labelListList&)` + +## MOAD +0001 — CWE-407 Algorithmic Complexity + +## Severity +HIGH + +## Pattern + +```cpp +DynamicList