VLSI DV Interview Puzzles · All levels

join_any Timeout Ghost Thread

A test sometimes passes then later crashes with timeout fatal. Why can this happen?

Puzzle

Difficulty: Medium · Puzzle 5 of 6 · Topic: Debugging Riddles

A test sometimes passes then later crashes with timeout fatal. Why can this happen?

Code

systemverilog
fork
  begin
    wait(done);
  end
  begin
    #1000 `uvm_fatal("TIMEOUT", "No completion")
  end
join_any
// missing disable fork

Hint

What happens to the losing forked branch after join_any?

Step-by-step solution

diagram
1) join_any returns when first branch finishes (e.g., done becomes true).
2) Other branch keeps running unless explicitly killed.
3) Timeout branch later reaches #1000 and calls fatal, even though operation succeeded.
4) Add disable fork immediately after join_any, or use structured timeout utility that cancels losing branch.

Answer

Answer: Missing `disable fork` leaves timeout thread alive; it fires later as a false fatal.

Why candidates get it wrong

Believing join_any automatically terminates other branches.

Interviewer follow-up

How would you write the same logic using `process` handles for explicit kill?

Related topics