From 6ba06498db2ff5aec7d5abd1c8d20cae99cbdf15 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 4 Apr 2025 08:15:39 -0400 Subject: [PATCH] Fix segfault in fork synchronization (#5906). --- Changes | 1 + src/V3Timing.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index b3afb7bef..1e77503fa 100644 --- a/Changes +++ b/Changes @@ -66,6 +66,7 @@ Verilator 5.035 devel * Fix process comparisons (#5896). * Fix ccache with clang (#5899). [Geza Lore] * Fix delayed assignment malformed LHS assertion (#5904). +* Fix segfault in fork synchronization (#5906). [Krzysztof Bieganski, Antmicro Ltd.] * Fix `new this` (#5909). diff --git a/src/V3Timing.cpp b/src/V3Timing.cpp index c586365af..09092095b 100644 --- a/src/V3Timing.cpp +++ b/src/V3Timing.cpp @@ -723,8 +723,8 @@ class TimingControlVisitor final : public VNVisitor { void makeForkJoin(AstFork* const forkp) { // Create a fork sync var FileLine* const flp = forkp->fileline(); - // If we're in a function, insert the sync var directly before the fork - AstNode* const insertBeforep = m_classp ? forkp : nullptr; + // Insert the sync var directly before the fork + AstNode* const insertBeforep = forkp; addCLocalScope(flp, insertBeforep); AstVarScope* forkVscp = createTemp(flp, forkp->name() + "__sync", getCreateForkSyncDTypep(), insertBeforep);