MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
558 stars 122 forks source link

slang-netlist: Assertion 'it != nodes.end() && "Could not find node"' failed #1007

Closed udif closed 3 weeks ago

udif commented 1 month ago

Describe the bug slang-netlist fails with an internal assertion when the following code is run: @jameshanlon

To Reproduce

module t34;
  reg  [3:0] x;
  reg   [15:0] v;

  always @(v)
  begin
    integer i;
    x = '0;
    for (i = 0; i <= 15; i = i + 1)
      if (v[i] == 1'b0)
        x = i;
  end
endmodule

Result:

% slang-netlist udif_tests/t34.v
Top level design units:
    t34

Build succeeded: 0 errors, 0 warnings
Assertion 'it != nodes.end() && "Could not find node"' failed
  in file /home/udif/git/slang/tools/netlist/include/DirectedGraph.h, line 188
  function: netlist::DirectedGraph<NodeType, EdgeType>::node_descriptor netlist::DirectedGraph<NodeType, EdgeType>::findNode(const NodeType&) const [with NodeType = netlist::NetlistNode; EdgeType = netlist::NetlistEdge; netlist::DirectedGraph<NodeType, EdgeType>::node_descriptor = long unsigned int]

While I suspected this was introduced as part of the comb-loops change, I still see it with an older copy of slang-netlist that predates this change:

% slang-netlist --version
slang-netlist version 5.0.196+28783e82

Additional context This is the bug I was referring to in https://github.com/MikePopoloski/slang/pull/1005#issue-2309577043 . I originally thought this was related to my changes, but apparently not. Also, it might be related to #993 as both issues involve blocking assignments, even though the bugs symptoms are different.

udif commented 1 month ago

Also verified with the last commit before the comb-loops commit:

% slang-netlist --version
slang-netlist version 6.0.50+56a10c53