Skip to content

odb: guard instance module reassignment#10921

Open
naveenvenk17 wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
naveenvenk17:nv-odb-module-callback
Open

odb: guard instance module reassignment#10921
naveenvenk17 wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
naveenvenk17:nv-odb-module-callback

Conversation

@naveenvenk17

Copy link
Copy Markdown
Contributor

Fixes #10282.

_dbInst::module_ could be assigned directly, so a future parent change could skip inDbPostInstParentChange and leave hierarchical path caches stale. This makes the field private and routes normal changes through setModule(). Database serialization and hash rebuilding retain narrow friend access.

While adding the regression I found that reparenting also left the instance in the old module name index. removeInst() now removes that stale entry before linking the instance into its new module.

The new test checks callback count and timing, same-parent no-op behavior, and both old and new module lookups.

Tested on the GCP VM:

  • bazel test //src/odb/test/cpp:all //src/dbSta/test:sdc_modinst_slash-tcl_test
  • bazel build --config=lint //src/odb/src/db:db //src/odb/test/cpp:TestModule

All 25 tests pass and the lint build passes.

Signed-off-by: Naveen Venkat <archgen.guest@nyayanidhi.in>
@naveenvenk17
naveenvenk17 requested a review from a team as a code owner July 15, 2026 11:31
@naveenvenk17
naveenvenk17 requested a review from maliberty July 15, 2026 11:31

@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 refactors how instance module membership is managed by encapsulating the _dbInst::module_ field with getModuleId() and setModule(), ensuring that the inDbPostInstParentChange callback is correctly triggered during reparenting. It also updates _dbModule::removeInst to clean up the instance from the module's dbinst_hash_ and adds corresponding unit tests. The review feedback identifies a critical correctness issue where renaming an instance via dbInst::rename does not update the parent module's dbinst_hash_, which can leave stale entries and lead to undefined behavior or use-after-free upon destruction. A code suggestion is provided to update dbInst::rename to handle this case.

Comment thread src/odb/src/db/dbModule.cpp
@naveenvenk17

Copy link
Copy Markdown
Contributor Author

I also ran the focused TestModule suite under ASan with #10911 layered underneath for the hermetic sanitizer runtime. It passes with leak detection disabled.

Signed-off-by: Naveen Venkat <archgen.guest@nyayanidhi.in>
Comment thread src/odb/src/db/dbInst.cpp
Comment on lines +85 to +87
if (previous == 0 || module == 0) {
return;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why skip the callback?

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.

odb: encapsulate _dbInst::module_ mutation through a setter that fires inDbPostInstParentChange

2 participants