Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
    • Testbench Debug Puzzles: Why Did the Test Hang?
    • Deadlock Scenario Puzzles: Objection and Phase Stalls
      • Early Return Leaves Objection Raised
      • fork...join_none Thread Leak
      • Semaphore Token Leak on Error Path
      • Mailbox Consumer Blocks Forever
      • Lock Inversion with Two Semaphores
      • Child Sequence Raises Objection but Never Drops
    • Scoreboard Puzzles: Mismatch or Ordering Bug?
    • Real Interview Rounds: End-to-End Debug Walkthrough
    • Scenario & Debug Puzzles: Tricky Q&A
  • Interview Prep: Puzzle Rounds5
  • DV Puzzle Cheatsheet
Loading lesson

‹Deadlock Scenario Puzzles: Objection and Phase Stalls
  1. Topics
  2. DV Interview Puzzles
  3. Scenario & Debug Puzzles
  4. Deadlock Scenario Puzzles: Objection and Phase Stalls
  5. Mailbox Consumer Blocks Forever

VLSI DV Interview Puzzles · All levels

Mailbox Consumer Blocks Forever

Collector thread blocks forever on mailbox get(). Producer thread silently died earlier. Find the control-flow interaction that causes permanent stall.

On this page

    Puzzle

    Difficulty: Medium · Puzzle 4 of 6 · Topic: Deadlock Scenario Puzzles: Objection and Phase Stalls

    Collector thread blocks forever on mailbox get(). Producer thread silently died earlier. Find the control-flow interaction that causes permanent stall.

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    mailbox #(pkt) mbx = new();
    
    task run_phase(uvm_phase phase);
      fork
        begin : producer
          repeat (100) begin
            pkt p = new();
            build_pkt(p);
            mbx.put(p);
          end
        end
        begin : consumer
          forever begin
            pkt q;
            mbx.get(q); // blocks forever after producer dies
            process_pkt(q);
          end
        end
      join_any
      disable producer; // bug: kills producer early, consumer still infinite
    endtask

    Hint

    join_any plus asymmetric disable is a common stall generator.

    Step-by-step solution

    Diagram
    1) Inspect fork control semantics and note consumer is unbounded forever loop.
    2) Observe join_any returns as soon as either branch exits.
    3) disable producer can terminate source while consumer continues blocking on empty mailbox.
    4) Introduce termination protocol: sentinels, stop event, or bounded consumer loop.
    5) Use try_get with wait/event/backoff if producer lifetime is dynamic.

    Answer

    Answer: Bug: fork control kills producer while consumer remains infinite blocking on mailbox.get. Fix: define explicit shutdown handshake or bounded loops so both threads terminate coherently.

    Why candidates get it wrong

    The stall is in TB orchestration, not mailbox implementation.

    Interviewer follow-up

    How would you redesign this with one supervisor thread owning both producer/consumer lifetime?

    Related topics

    • Back to Deadlock Scenario Puzzles: Objection and Phase Stalls

    • Scenario & Debug Puzzles section

    Previous

    189 / 210

    Next: Lock Inversion with Two Semaphores

    Up next

    Up nextLock Inversion with Two Semaphores

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Early Return Leaves Objection Raised
    • fork...join_none Thread Leak
    • Child Sequence Raises Objection but Never Drops