java-topology/tools/tickets/defects/erlang-0001.md
russell@unturf.com db29a08762 undefect. CWE-407 — 92 sites, 42 ecosystems
B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections.
Squash of 94 local commits onto remote master.
2026-03-26 19:48:18 -04:00

1.1 KiB

id repo severity status created
erlang-0001 otp HIGH PATCHED 2026-03-23

Defect

File: lib/stdlib/src/digraph.erl:578 Pattern: lists:member(V, Xs) in one_path/8 — used by get_path, get_cycle, get_short_path Complexity: O(V²) Language: Erlang

Description

one_path/8 in Erlang's stdlib digraph module tracks visited vertices using a plain list Xs and tests membership with lists:member(V, Xs). This function is the underlying implementation for get_path, get_cycle, and get_short_path. For each vertex visited during path search, the full visited list is scanned linearly, resulting in O(V²) total work for paths of length V through the graph.

Fix

Replace: lists:member(V, Xs) With: sets:is_element(V, XsSet) Data structure change: Xs: list() → XsSet: sets:set()

Work required

  • Patch in defects/erlang/patch/
  • Unit test — asserts exact operation counts before/after (in defects/erlang/unit/)
  • Integration test (in defects/erlang/integration/)
  • Benchmark — before/after on V=100,200,400,800 (in defects/erlang/bench/)
  • White paper section