Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguity in NDR crashes OpenROAD #6706

Open
AkaBlur opened this issue Feb 13, 2025 · 1 comment
Open

Ambiguity in NDR crashes OpenROAD #6706

AkaBlur opened this issue Feb 13, 2025 · 1 comment
Assignees
Labels
odb OpenDB

Comments

@AkaBlur
Copy link

AkaBlur commented Feb 13, 2025

Describe the bug

create_ndr allows spacing, width and via as optional parameter to create an NDR.
When creating an NDR with just VIAs to force their usage OpenROAD crashes.

When adding either spacing or width to the list of arguments the crash doesn't occur.

This might be also related to #4194

Expected Behavior

Clarify the usage of create_ndr so it doesn't allow via without the other parameters
or no crashing when using just via.

This would also clarify NDR to be able to set VIA types for a given net or to just add additional metal rules.

Environment

[WARNING] Your current OpenROAD version is outdated.
It is recommened to pull the latest changes.
If problem persists, file a github issue with the re-producible test case.
kernel: Linux 3.10.0-1160.88.1.el7.x86_64
os: Ubuntu 22.04.4 LTS (Jammy Jellyfish)
cmake version 3.22.1
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- OpenROAD version: v2.0-18983-g82b211d32
-- System name: Linux
-- Compiler: GNU 11.4.0
-- Build type: RELEASE
-- Install prefix: /usr/local
-- C++ Standard: 17
-- C++ Standard Required: ON
-- C++ Extensions: OFF
-- The C compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test C_COMPILER_SUPPORTS__-Wall
-- Performing Test C_COMPILER_SUPPORTS__-Wall - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wall
-- Performing Test CXX_COMPILER_SUPPORTS__-Wall - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-array-bounds
-- Performing Test C_COMPILER_SUPPORTS__-Wno-array-bounds - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-array-bounds
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-array-bounds - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-nonnull
-- Performing Test C_COMPILER_SUPPORTS__-Wno-nonnull - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-nonnull
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-nonnull - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-maybe-uninitialized
-- Performing Test C_COMPILER_SUPPORTS__-Wno-maybe-uninitialized - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-maybe-uninitialized
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-maybe-uninitialized - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-format-overflow
-- Performing Test C_COMPILER_SUPPORTS__-Wno-format-overflow - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-format-overflow
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-format-overflow - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-variable
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-variable - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-variable
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-variable - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-function
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-function - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-function
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-function - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-write-strings
-- Performing Test C_COMPILER_SUPPORTS__-Wno-write-strings - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-write-strings
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-write-strings - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-sign-compare
-- Performing Test C_COMPILER_SUPPORTS__-Wno-sign-compare - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-sign-compare
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-sign-compare - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-deprecated
-- Performing Test C_COMPILER_SUPPORTS__-Wno-deprecated - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-deprecated
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-deprecated - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-c++11-narrowing
-- Performing Test C_COMPILER_SUPPORTS__-Wno-c++11-narrowing - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-c++11-narrowing
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-c++11-narrowing - Failed
-- Performing Test C_COMPILER_SUPPORTS__-Wno-register
-- Performing Test C_COMPILER_SUPPORTS__-Wno-register - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-register
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-register - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-format
-- Performing Test C_COMPILER_SUPPORTS__-Wno-format - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-format
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-format - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-reserved-user-defined-literal
-- PerformingCMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR) (Required is at
  least version "4.0")
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.22/Modules/FindSWIG.cmake:153 (find_package_handle_standard_args)
  src/CMakeLists.txt:169 (find_package)


 Test C_COMPILER_SUPPORTS__-Wno-reserved-user-defined-literal - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-reserved-user-defined-literal
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-reserved-user-defined-literal - Failed
-- Performing Test C_COMPILER_SUPPORTS__-fpermissive
-- Performing Test C_COMPILER_SUPPORTS__-fpermissive - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-fpermissive
-- Performing Test CXX_COMPILER_SUPPORTS__-fpermissive - Success
-- Performing Test C_COMPILER_SUPPORTS__-x
-- Performing Test C_COMPILER_SUPPORTS__-x - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-x
-- Performing Test CXX_COMPILER_SUPPORTS__-x - Failed
-- Performing Test C_COMPILER_SUPPORTS__c++
-- Performing Test C_COMPILER_SUPPORTS__c++ - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__c++
-- Performing Test CXX_COMPILER_SUPPORTS__c++ - Failed
-- Performing Test C_COMPILER_SUPPORTS__-std=c++17
-- Performing Test C_COMPILER_SUPPORTS__-std=c++17 - Failed
-- Performing Test CXX_COMPILER_SUPPORTS__-std=c++17
-- Performing Test CXX_COMPILER_SUPPORTS__-std=c++17 - Success
-- Performing Test C_COMPILER_SUPPORTS__-fno-exceptions
-- Performing Test C_COMPILER_SUPPORTS__-fno-exceptions - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-fno-exceptions
-- Performing Test CXX_COMPILER_SUPPORTS__-fno-exceptions - Success
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-but-set-variable
-- Performing Test C_COMPILER_SUPPORTS__-Wno-unused-but-set-variable - Success
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-but-set-variable
-- Performing Test CXX_COMPILER_SUPPORTS__-Wno-unused-but-set-variable - Success
-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- TCL library: /usr/lib/x86_64-linux-gnu/libtcl.so
-- TCL header: /usr/include/tcl/tcl.h
-- TCL readline library: /usr/lib/x86_64-linux-gnu/libtclreadline.so
-- TCL readline header: /usr/include/x86_64-linux-gnu
-- Configuring incomplete, errors occurred!

To Reproduce

Use the included testcase: nangate45/gcd

Inside the config.mk of the design add:

export PRE_GLOBAL_ROUTE = $(DESIGN_HOME)/$(PLATFORM)/$(DESIGN_NICKNAME)/via_ndr.tcl

Create via_ndr.tcl inside the design directory with the following contents:

create_ndr -name VIA_select -via { \
    via1_0 \
    via2_0 \
    via3_0 \
    via4_0 \
    via5_0 \
    via6_0 \
    via7_0 \
    via8_0 \
    via9_0 \
}

assign_ndr -ndr VIA_select -net clk

This will crash OpenROAD.

However when adding width it completes routing without any errors:

...
create_ndr -name VIA_select -width 0.15 -via { \
...

Relevant log output

[INFO DRT-0180] Post processing.
Signal 11 received
Stack trace:
 0# 0x000055D0E2F34BAB in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
 1# 0x00007FD6B95D7520 in /lib/x86_64-linux-gnu/libc.so.6
 2# odb::dbWireEncoder::initPath(odb::dbTechLayer*, unsigned char, odb::dbTechLayerRule*) in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
 3# odb::dbWireEncoder::newPath(odb::dbTechLayer*, odb::dbWireType, odb::dbTechLayerRule*) in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
 4# drt::io::Writer::updateDbConn(odb::dbBlock*, odb::dbTech*, bool) in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
 5# drt::io::Writer::updateDb(odb::dbDatabase*, drt::RouterConfiguration*, bool, bool) in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
 6# drt::TritonRoute::endFR() in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
 7# drt::TritonRoute::main() in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
 8# detailed_route_cmd(char const*, char const*, char const*, char const*, char const*, bool, int, char const*, char const*, int, double, char const*, char const*, int, bool, bool, bool, int, bool, char const*, int) in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
 9# 0x000055D0E396E22A in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
10# TclNRRunCallbacks in /lib/x86_64-linux-gnu/libtcl8.6.so
11# 0x00007FD6BDB29028 in /lib/x86_64-linux-gnu/libtcl8.6.so
12# Tcl_EvalEx in /lib/x86_64-linux-gnu/libtcl8.6.so
13# Tcl_Eval in /lib/x86_64-linux-gnu/libtcl8.6.so
14# sta::sourceTclFile(char const*, bool, bool, Tcl_Interp*) in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
15# 0x000055D0E2F3439C in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
16# Tcl_MainEx in /lib/x86_64-linux-gnu/libtcl8.6.so
17# main in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
18# 0x00007FD6B95BED90 in /lib/x86_64-linux-gnu/libc.so.6
19# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
20# _start in /home/docker/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad
Command terminated by signal 11
Elapsed time: 1:07.08[h:]min:sec. CPU time: user 216.60 sys 1.74 (325%). Peak memory: 1275584KB.
make[1]: *** [Makefile:739: do-5_2_route] Error 139
make: *** [Makefile:737: results/nangate45/gcd/base/5_2_route.odb] Error 2

Screenshots

No response

Additional Context

I've already done some investigation why this is happening. As mentioned, I think the option to allow via without anything else causes the problem:

odb.tcl only calls addUseVia on a created NDR, whereas width and spacing call set_ndr_rules. set_ndr_rules in the end execute odb::dbTechLayerRule.create() with the specified NDR.

The crash comes from src/drt/src/io/io.cpp when accessing the layer rule from a given NDR. As far as my understanding goes for this, the NDR has been instantiated initially by the TCL command, but no layer rules have been set. When the NDR gets created in src/odb/src/db/dbTechNonDefaultRule.cpp all the layer rules inside the vector _layer_rules are filled with 0. When trying to access the rule from a layer with 0 dbTechNonDefaultRule::getLayerRule return nullptr.

This will then cause the router to try and create a path with the nullptr in:

_wire_encoder.newPath(
                  layer,
                  odb::dbWireType("ROUTED"),
                  net->getNonDefaultRule()->getLayerRule(layer));

So basically newPath tries to dereferences the pointer which leads to the crash.

If I understood the implementation correct this would mean NDRs can only be used with a given layer rule? So this must then either be set
by the TCL interpreter or disabled for protection against random crashing of the router.

Also I'm not sure why OpenROAD complains to be outdated, I pulled d62c05a8 from today and rebuilt it before trying this testcase.

@maliberty
Copy link
Member

We should require all layers to be specified. A via only ndr is invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
odb OpenDB
Projects
None yet
Development

No branches or pull requests

3 participants