java-topology/tools/tickets/scans/yosys.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

2.2 KiB

id priority status created
scan-yosys high unscanned 2026-03-23

Target

Repo: https://github.com/YosysHQ/yosys Language: C++ Why: Open-source chip synthesis used in FPGA and ASIC design — linear visited-node scans in technology-mapping DAG traversal inflate synthesis runtime on large designs.

Scan command

# Shallow clone
git clone --depth 1 https://github.com/YosysHQ/yosys /tmp/yosys

# Submit to unsandbox
cat > /tmp/scan-yosys.sh << 'EOF'
#!/usr/bin/env bash
set -euo pipefail
GRAPH_KW="tarjan|strongly.connected|dfs|scc|topolog|topo.sort|cycle|reachab|postorder|dominator|liveness|digraph|shortest.path|path.find"
MEM="std::find|\.count\(|vector.*find|find.*begin.*end|push_back.*visited|visited\.push_back"
find /tmp/yosys/kernel /tmp/yosys/passes -name "*.cc" -o -name "*.h" | sort | while read f; do
  graph_lines=$(grep -inE "$GRAPH_KW" "$f" 2>/dev/null | cut -d: -f1 | head -5 || true)
  [ -z "$graph_lines" ] && continue
  while IFS= read -r lineno; do
    s=$(( lineno > 20 ? lineno - 20 : 1 )); e=$(( lineno + 20 ))
    hit=$(sed -n "${s},${e}p" "$f" 2>/dev/null | grep -iE "$MEM" | head -1 | sed 's/^\s*//' || true)
    [ -n "$hit" ] && echo "CANDIDATE\t${f}:${lineno}\t${hit}"
  done <<< "$graph_lines"
done
EOF
export UNSANDBOX_PUBLIC_KEY=unsb-pk-russ-test-isth-best
export UNSANDBOX_SECRET_KEY=unsb-sk-rk46c-3zvpg-zjf6z-hjrge
~/git/un-inception/build/un /tmp/scan-yosys.sh

Key files to check

  • kernel/rtlil.cc — Core RTLIL data structures; module/cell graph iteration
  • passes/opt/ — Optimization passes; DAG traversal for constant propagation and merging
  • passes/techmap/ — Technology mapping; pattern-matching over DAG with visited tracking
  • kernel/celltypes.cc — Cell type graph; any topological enumeration

Expected pattern

std::find(vec.begin(), vec.end(), cell) where vec is a std::vector<Cell*> used as a visited set inside a DFS or topological sort in one of the optimization or tech-mapping passes — should use std::unordered_set<Cell*>.

Acceptance criteria

  • Scan run and results saved to tools/scan-results/yosys.txt
  • All CANDIDATE hits triaged (confirmed defect or false positive)
  • If confirmed: defect ticket created in tools/tickets/defects/