SystemVerilog OOP Mastery · All levels
Tricky Pitfalls & Debug: Tricky Q&A
Rapid-fire interview Q&A for Tricky Pitfalls & Debug.
Section Q&A
Rapid-fire interview questions for Tricky Pitfalls & Debug. Answer out loud, then check yourself.
Q1. A null-handle crash shows up in scoreboard code, but sequence code allocates the object in most runs. What is your first debug move?
Answer: Trace ownership edges instead of patching dereference sites. Log creation and handoff points with IDs, then assert non-null at each boundary. The first missing handoff usually reveals the true bug.
Trap: Adding defensive null checks at every call site and hiding the missing-construction path.
Q2. Expected and actual values drift together across cycles. How do you prove aliasing in minutes?
Answer: Print %p for top-level and nested handles at capture and compare time. If supposed snapshots share identities, you have aliasing; fix clone/copy to deep-copy owned handles.
Trap: Confirming only top-level handles and missing nested payload aliasing.
Q3. A derived method exists and works in unit tests, but framework logs still show base behavior. Why?
Answer: Framework stores objects as base handles. If the base declaration is nonvirtual, dispatch is static and calls stay in base implementation even when runtime type is derived.
Trap: Making only the derived method virtual and assuming dynamic dispatch is enabled.
Q4. When should static state be in a parameterized class versus a shared base class?
Answer: Put static in the parameterized class for per-specialization state; put it in a non-parameterized base only for intentional global sharing. Validate behavior across multiple specializations in tests.
Trap: Relying on assumed static scoping without a cross-specialization check.