dft: ScanStitch::Stitch dereferences std::deque::end() on chains of 3+ cells

Chiusa Adatta ai principianti
#11,985 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mmporong ci sta già lavorando.

Dal 26/10/2026.

  • #11995 di @mmporong — aperta
  • #12011 di @shivarammysore — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
testing-qa

Direzione di ricerca

Inizia in src/dft/src/stitch/ScanStitch.cpp, in corrispondenza di ScanStitch::Stitch, e segui come viene formata la deque e come vengono collegate la prima e l’ultima cella. L’issue indica src/dft/test/scan_architect_no_mix_sky130.tcl come riproduttore; eseguilo con una libreria standard hardened o con ASan per evidenziare l’accesso non valido. Il lavoro è completato quando le catene di tre o più celle vengono collegate in ordine senza dereferenziare oltre la deque, preservando l’ordine di connessione indicato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

dft

ScanStitch::Stitch(block, scan_chain, ordinal) in src/dft/src/stitch/ScanStitch.cpp dereferences std::deque::end() when a chain has 3 or more cells, which is undefined behaviour.

The chain's cells are copied into a std::deque, the first and last are popped off, and the middle cells are walked with:

for (auto it = scan_cells.begin(); it != scan_cells.end(); ++it) {
  const std::unique_ptr<ScanCell>& current = *it;
  const std::unique_ptr<ScanCell>& next = *(it + 1);
  next->connectScanIn(current->getScanOut());
}

On the last middle cell, it + 1 == scan_cells.end(), so next is read from past the end.

Why the regressions pass anyway: with libc++, the slot just past the end still holds the element that pop_back() removed, which is the last cell of the chain. So the read returns the last cell, and the last cell's scan-in ends up connected to the last middle cell's scan-out. Nothing else connects the last cell when there are 3+ cells; the explicit "connect the last cell" branch only runs when the middle is empty. The correct result therefore depends on the stale slot.

Reproducer: any execute_dft_plan that builds a chain of 3 or more cells, e.g. src/dft/test/scan_architect_no_mix_sky130.tcl. A hardened standard library (libc++ hardened mode, _GLIBCXX_ASSERTIONS) or ASan should flag the dereference. A different standard library, or a deque layout where that slot is no longer the popped element, could connect the wrong cell or crash.

Suggested fix: connect the cells pairwise in chain order instead of popping both ends, e.g. after connecting the first cell's scan-in, for i in 1..n: cells[i]->connectScanIn(cells[i-1]->getScanOut()), then the last cell's scan-out as today. The connections, and the order they are made in, stay what the current binary produces.

Seen at 27288f5c90 and still present on master (3c92de5213).

Lingua principale
Verilog
Stelle
3.3k
Fork
1.1k
Merge medio
2g 14h
PR unite (30g)
277

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di The-OpenROAD-Project/OpenROAD

Tutte le issue di The-OpenROAD-Project/OpenROAD

Issue simili

Altre issue su Testing & QA

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.