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,59 @@
# UNDF: (leave blank)
# Defect: kdenlive-0009
# Component: src/core.cpp + src/mainwindow.h — buildLumaThumbs / m_lumacache
# MOAD: 0005 (Thundering Herd / CWE-362) — concurrent cache get+null+compute+put without lock
# Severity: HIGH — data race on QMap<QString, QImage> from QtConcurrent worker vs UI thread
#
# buildLumaThumbs() is called via QtConcurrent::run() (a worker thread) in
# src/mltconnection.cpp:455. It reads and writes MainWindow::m_lumacache, a
# static QMap<QString, QImage>, without any mutex.
#
# Concurrently, UI widget code (urllistparamwidget.cpp, listparamwidget.cpp,
# listdependencyparamwidget.cpp, slideshowclip.cpp, core.cpp) reads and writes
# the same map from the main thread.
#
# QMap is not thread-safe for concurrent writes from different threads.
# A concurrent insert() + rehash from the worker thread and any read/write from
# the UI thread is undefined behavior — likely manifesting as random crashes or
# corrupted thumbnails during project load.
#
# Fix: add a QMutex to protect all m_lumacache accesses.
#
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -103,8 +103,10 @@
static QMap<QString, QImage> m_lumacache;
+ static QMutex m_lumacacheMutex;
/** @brief List of all luma files to use when rendering transitions */
static QStringList m_lumaFiles;
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -133,2 +133,3 @@
QMap<QString, QImage> MainWindow::m_lumacache;
+QMutex MainWindow::m_lumacacheMutex;
--- a/src/core.cpp
+++ b/src/core.cpp
@@ buildLumaThumbs
void Core::buildLumaThumbs(const QStringList &values)
{
for (auto &entry : values) {
- if (MainWindow::m_lumacache.contains(entry)) {
+ QMutexLocker locker(&MainWindow::m_lumacacheMutex);
+ if (MainWindow::m_lumacache.contains(entry)) {
continue;
}
QImage pix(entry);
if (!pix.isNull()) {
MainWindow::m_lumacache.insert(entry, pix.scaled(50, 30, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
+ // locker released at end of loop iteration
}
}
# Note: all other m_lumacache read sites (urllistparamwidget.cpp lines 204-205, 363, 393;
# listparamwidget.cpp lines 88-89; listdependencyparamwidget.cpp lines 157-158;
# slideshowclip.cpp lines 148-154; core.cpp line 656) must also hold m_lumacacheMutex
# before accessing the cache. Those sites run on the main thread, so the locker
# adds only minimal overhead there.

View file

@ -0,0 +1,49 @@
# Kdenlive — Full 5-MOAD Scan 2026-03-31
Source: https://github.com/KDE/kdenlive (depth=1, HEAD ~2026-03)
## MOAD-0001 (CWE-407) — 9 defects total (8 pre-existing, 1 new)
Pre-existing (patches kdenlive-0001 through kdenlive-0008 already exist):
- 0001: ThumbnailCache storedOnDisk vector linear find
- 0002: TimelineModel clipIds std::find in mix loop
- 0003: TimelineController sorted_clips std::find in moveGroup
- 0004: TimelineModel all_items std::find in resize
- 0005: PreviewManager m_renderedChunks/m_dirtyChunks QVariantList contains
- 0006: TimelineController canceled guides vector std::find
- 0007: AssetParameterModel m_rows indexOf in loops
- 0008: UrlListParamWidget addItemsInSameFolder std::find on map values
No new CWE-407 defects found in this scan pass.
## MOAD-0002 (Intertangle) — OBSERVATION (no patch)
`pCore` global singleton is referenced 3704 times across the codebase. Classic
god-object Intertangle: timeline, bin, effects, render, scripting, and UI all
couple through `pCore->...`. Refactoring scope is architectural and out of band
for this scan. Noted as technical debt, not patched.
## MOAD-0003 (Leaked Context) — CLEAN
`src/logger.cpp` has two `thread_local` variables:
- `Logger::is_executing` — execution guard flag, not request-scoped identity
- `Logger::result_awaiting` — undo/redo result index, not request-scoped identity
No ThreadLocal holding request-scoped user identity or credentials found.
## MOAD-0004 (CWE-312 Logged Secret) — CLEAN
No credential logging found. Grep for password/token/secret/api_key in
qCDebug/qDebug/qWarning output returned no results in `src/`.
## MOAD-0005 (Thundering Herd) — 1 new defect: kdenlive-0009
`Core::buildLumaThumbs()` is launched via `QtConcurrent::run()` (worker thread)
and reads/writes `MainWindow::m_lumacache` (a `QMap<QString, QImage>`) without
any mutex. UI widgets (urllistparamwidget.cpp, listparamwidget.cpp,
listdependencyparamwidget.cpp, slideshowclip.cpp) also read/write the same map
from the main thread. QMap is not thread-safe for concurrent access from multiple
threads. This is a data race — undefined behavior, likely random crashes or
corrupted thumbnails during project load.
Patch: kdenlive-0009-lumacache-qtconcurrent-race.patch