Skip to content

web: Guard chiplet orientation test lookup - #11651

Open
jhkim-pii wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:coverity-fix-pr11429
Open

jhkim-pii wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:coverity-fix-pr11429

Conversation

@jhkim-pii

Copy link
Copy Markdown
Contributor

Coverity Defect Log

** CID 1687965:       Null pointer dereferences  (FORWARD_NULL)


_____________________________________________________________________________________________
*** CID 1687965:         Null pointer dereferences  (FORWARD_NULL)
/src/web/test/cpp/TestTileGenerator.cpp: 2172             in web::<unnamed>::TileGeneratorTest_TechResponseReportsTheFullOrientation_Test::TestBody()()
2166         if (entry.as_object().at("name").as_string() == die0->getName()) {
2167           die_entry = &entry.as_object();
2168           break;
2169         }
2170       }
2171       ASSERT_NE(die_entry, nullptr);
>>>     CID 1687965:         Null pointer dereferences  (FORWARD_NULL)
>>>     Passing null pointer "die_entry" to "at", which dereferences it.
2172       EXPECT_EQ(die_entry->at("orient").as_string(), "MZ")
2173           << "the 3D orientation collapsed to its 2D half, losing the flip";
2174       EXPECT_TRUE(die_entry->at("mirror_z").as_bool());
2175     
2176       // layer_hierarchy carries it too: that is the tree the frontend walks when
2177       // it assigns z-indices.

Solution

CID Defect type Resolution
1687965 FORWARD_NULL Fail and return before dereferencing missing chiplet or Backside hierarchy entries.

Related

Replace the fatal assertion with an explicit failure and return before using the chiplet JSON entry pointer. Coverity does not infer the assertion macro control flow and reports a possible null dereference.

The test still fails immediately when the expected chiplet entry is absent.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Use an explicit failure-and-return guard for the Backside category search, matching the chiplet lookup already fixed in this PR. The ASSERT_NE macro can hide null control flow from Coverity; the branch preserves test failure and prevents the dereference.

Address the reviewer-requested matching lookup without changing production logic.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@jhkim-pii jhkim-pii self-assigned this Oct 7, 2026
@github-actions github-actions Bot added the size/S label Oct 7, 2026
@jhkim-pii
jhkim-pii marked this pull request as ready for review October 7, 2026 00:22
@jhkim-pii
jhkim-pii requested a review from a team as a code owner October 7, 2026 00:22
@jhkim-pii
jhkim-pii requested a review from gadfort October 7, 2026 00:22

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces ASSERT_NE assertions with manual nullptr checks using ADD_FAILURE() and explicit returns in TestTileGenerator.cpp. The feedback suggests using the more idiomatic Google Test FAIL() macro instead, which automatically generates a fatal failure and returns from the function, simplifying the code.

Comment on lines +2171 to +2174
if (die_entry == nullptr) {
ADD_FAILURE() << "tech response has no chiplet " << die0->getName();
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In Google Test, FAIL() is a fatal assertion macro that automatically generates a failure and returns from the current function. Using FAIL() is more concise and idiomatic than combining ADD_FAILURE() with an explicit return; statement.

  if (die_entry == nullptr) {
    FAIL() << "tech response has no chiplet " << die0->getName();
  }

Comment on lines +4952 to +4955
if (backside_node == nullptr) {
ADD_FAILURE() << "layer_hierarchy missing Backside category node";
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similarly, FAIL() can be used here to simplify the fatal failure and return logic into a single idiomatic Google Test macro call.

  if (backside_node == nullptr) {
    FAIL() << "layer_hierarchy missing Backside category node";
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant