The-OpenROAD-Project / The-OpenROAD-Project/OpenROAD

sv_elaborate crashes with SIGSEGV

Open
#11,024 0 comments 0 reactions 1 assignee View on GitHub

@maliberty is already working on this.

Since Aug 19, 2026.

syn
Dominant language
Verilog
Stars
3.1k
Forks
1k
Avg merge
2d 23h
Merged PRs (30d)
136

Description

Describe the bug

When elaborating SystemVerilog designs using sv_elaborate (the Slang frontend), OpenROAD crashes with a SIGSEGV (or UndefinedBehaviorSanitizer: invalid-bool-load under ASan/UBSan) if the design contains a conditional generate block (if-generate or case-generate) with internal nets or variables.

Expected Behavior

No error.

Environment
Git Commit: 34075db75016d6f080abe02a9cc4760c2af50768 (Latest upstream master)
OS / Kernel: Debian GNU/Linux rodete (6.18.14-1rodete3-amd64)
CMake: 3.31.9
Python: 3.10.6
SWIG: 4.3.0
Slang Version: 10.0.150+f04e81565
Yosys-Slang Revision: 82effc8d9541be69e1ed3ec44759a4449f5d9247

Note I didn't use cmake while reproducing this.
To Reproduce
bazelisk build --copt=-fsanitize=undefined --linkopt=-fno-sanitize-link-runtime //:openroad && ASAN_OPTIONS=detect_leaks=0:halt_on_error=1 ./bazel-bin/openroad -no_splash <<< "sv_elaborate --top top <(echo 'module top; if (1) begin : g wire w; end endmodule'); exit"

You may need to point to a specific asan library like --linkopt=/usr/lib/x86_64-linux-gnu/libubsan.so.1 and/or LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.8, but hopefully not.

This sigsegvs and gives the following backtrace (obtained seperately):

#0  slang_frontend::build_hierpath2(NetlistContext&, ostringstream&, Scope const*, string const&)
    at third-party/slang-elab/src/slang_frontend.cc:2520
#1  slang_frontend::build_hiername(NetlistContext&, Symbol const&, string const&)
    at third-party/slang-elab/src/slang_frontend.cc:2632
#2  slang_frontend::PopulateNetlist::add_internal_wires(InstanceBodySymbol const&)
    at third-party/slang-elab/src/slang_frontend.cc:2158
#3  slang::ast::ASTVisitor::visitDefault<slang::ast::GenerateBlockSymbol>(GenerateBlockSymbol const&)
#4  slang::ast::ASTVisitor::visitDefault<slang::ast::InstanceBodySymbol>(InstanceBodySymbol const&)
#5  slang_frontend::populate_netlist(HierarchyQueue&, NetlistContext&)
    at third-party/slang-elab/src/slang_frontend.cc:2208
#6  syn::elaborateImpl(...) at src/syn/src/elab/driver.cc:151
#7  syn::Synthesis::svElaborate(...) at src/syn/src/synthesis.cpp:44
Relevant log output

Screenshots

No response

Additional Context

In Slang GenerateBlockSymbol stores its loop iteration index and conditional branch expression in an anonymous union:

struct GenerateBlockSymbol : public Scope, public Symbol {
    union {
        const SVInt* arrayIndex = nullptr;
        const Expression* conditionExpression;
    };
    /// Returns the loop-iteration index, or nullptr if this block is not a loop iteration.
    const SVInt* getArrayIndex() const {
        return branchKind == GenerateBranchKind::LoopIteration ? arrayIndex : nullptr;
    }
};

In OpenROAD's slang-elab frontend the code directly accesses block.arrayIndex instead of using the safe accessor block.getArrayIndex(). https://github.com/povik/sv-elab/blob/82effc8d9541be69e1ed3ec44759a4449f5d9247/src/slang_frontend.cc#L2519

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.