kdenlive+audacity: 5-MOAD scan complete; kdenlive-0009 MOAD-0005 new defect

kdenlive: all 5 MOADs scanned.
- MOAD-0001: 8 pre-existing CWE-407 patches confirmed, no new sites found.
- MOAD-0002: pCore god object (3704 refs) noted as Intertangle observation.
- MOAD-0003: CLEAN (thread_local is execution guard, not request identity).
- MOAD-0004: CLEAN (no credential logging).
- MOAD-0005 NEW: buildLumaThumbs() called via QtConcurrent::run() writes
  to MainWindow::m_lumacache (QMap, not thread-safe) without mutex while UI
  widgets read/write the same map from the main thread — data race on project
  load. Patch: add QMutex, wrap all m_lumacache access sites.

audacity: all 5 MOADs scanned.
- MOAD-0001: 2 pre-existing CWE-407 patches confirmed, no new sites found.
- MOAD-0002 through MOAD-0005: CLEAN.

9/9 KdenliveTest PASS (added kdenlive-0009 MOAD-0005 threading test).
This commit is contained in:
russell@unturf.com 2026-03-31 21:13:14 -04:00
parent fb090af082
commit 282282447c
12 changed files with 890 additions and 1 deletions

View file

@ -0,0 +1,97 @@
--- a/modules/dnn/src/onnx/onnx_importer.cpp
+++ b/modules/dnn/src/onnx/onnx_importer.cpp
@@ -724,38 +724,44 @@ std::string ONNXImporter::getLayerTypeDomain(const opencv_onnx::NodeProto& node_
static bool ifInt8Output(const String& layerType)
{
- // Contains all node types whose output should be int8 when it get int8 input.
- // ai.onnx opset 15
- // FIXME: This search might be better in time once we start using string
- static std::vector<String> input8output8List = {
- "QuantizeLinear",
- "QLinearAdd",
- "QLinearMul",
- "QLinearAveragePool",
- "QLinearGlobalAveragePool",
- "QLinearLeakyRelu",
- "QLinearSigmoid",
- "QLinearConcat",
- "QGemm",
- "QLinearSoftmax",
- "QLinearConv",
- "QLinearMatMul",
- "MaxPool",
- "ReduceMax",
- "ReduceMin",
- "Split",
- "Clip",
- "Abs",
- "Transpose",
- "Squeeze",
- "Flatten",
- "Unsqueeze",
- "Expand",
- "Reshape",
- "Pad",
- "Gather",
- "Concat",
- "Resize",
- "SpaceToDepth",
- "DepthToSpace",
- "Pow",
- "Add",
- "Sub",
- "Mul",
- "Div"
- };
- auto layerIt = std::find(input8output8List.begin(), input8output8List.end(), layerType);
- return layerIt != input8output8List.end();
+ // Contains all node types whose output should be int8 when it get int8 input.
+ // ai.onnx opset 15
+ //
+ // CWE-407 fix: replaced static vector<String> + std::find (O(L) per call)
+ // with static unordered_set<String> (O(1) per call).
+ //
+ // ifInt8Output() is called once per ONNX node input inside setParamsDtype(),
+ // which is called for every node in populateNet(). A model with N nodes
+ // and I inputs per node incurs O(N*I*L) work with a vector (L=35 entries).
+ // With an unordered_set the same work is O(N*I). For large transformer
+ // models (N=1000 nodes, I=3 inputs) the saving is ~35x.
+ static const std::unordered_set<String> input8output8Set = {
+ "QuantizeLinear",
+ "QLinearAdd",
+ "QLinearMul",
+ "QLinearAveragePool",
+ "QLinearGlobalAveragePool",
+ "QLinearLeakyRelu",
+ "QLinearSigmoid",
+ "QLinearConcat",
+ "QGemm",
+ "QLinearSoftmax",
+ "QLinearConv",
+ "QLinearMatMul",
+ "MaxPool",
+ "ReduceMax",
+ "ReduceMin",
+ "Split",
+ "Clip",
+ "Abs",
+ "Transpose",
+ "Squeeze",
+ "Flatten",
+ "Unsqueeze",
+ "Expand",
+ "Reshape",
+ "Pad",
+ "Gather",
+ "Concat",
+ "Resize",
+ "SpaceToDepth",
+ "DepthToSpace",
+ "Pow",
+ "Add",
+ "Sub",
+ "Mul",
+ "Div"
+ };
+ return input8output8Set.count(layerType) > 0;
}