java-topology/defects/wine-0001/patch/wine-0001-loader-dependency-dedup.patch

28 lines
1.1 KiB
Diff

# UNDF: UNDF-2026-000000886
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -860,16 +860,22 @@
static LDR_DEPENDENCY *find_module_dependency( LDR_DDAG_NODE *from, LDR_DDAG_NODE *to )
{
+ /* DEFECT: O(D) linear scan through circular singly-linked list of
+ * dependencies. Called from add_module_dependency_after() on every
+ * DLL import, yielding O(I*D) per module where I = imports and
+ * D = accumulated dependencies. For complex DLL trees with hundreds
+ * of imports this is quadratic.
+ *
+ * Ideal fix: maintain a hash set (e.g. wine_rb_tree keyed on
+ * dependency_to pointer) alongside the linked list. Check the
+ * hash set for O(1) dedup instead of walking the list.
+ * The linked list must be preserved for Windows ABI compatibility. */
SINGLE_LIST_ENTRY *entry, *mark = from->Dependencies.Tail;
if (!mark) return NULL;
for (entry = mark->Next; entry != mark; entry = entry->Next)
{
LDR_DEPENDENCY *dep = CONTAINING_RECORD( entry, LDR_DEPENDENCY, dependency_to_entry );
if (dep->dependency_to == to && dep->dependency_from == from) return dep;
}
return NULL;
}