odb: initialize all tables in _dbDatabase::clear() constructor#10637
odb: initialize all tables in _dbDatabase::clear() constructor#10637osamahammad21 wants to merge 1 commit into
Conversation
Signed-off-by: osamahammad21 <osama@precisioninno.com>
There was a problem hiding this comment.
Code Review
This pull request initializes several new database tables (such as alignment marker rules, chip instances, and unfolded chip tables) in the dbDatabase constructor, and relocates the initialization of prop_tbl. Feedback on the changes points out a critical issue where logger_ is initialized to nullptr during reconstruction (e.g., in dbDatabase::clear()), which can lead to program termination during subsequent logging operations. It is recommended to initialize logger_ to utl::Logger::defaultLogger() to avoid this.
| dbu_per_micron_ = 0; | ||
| hierarchy_ = false; | ||
|
|
||
| alignment_marker_rule_tbl_ = new dbTable<_dbAlignmentMarkerRule>( |
There was a problem hiding this comment.
In the placement-new constructor _dbDatabase::_dbDatabase(_dbDatabase*, int id), logger_ is initialized to nullptr (at line 612). Since dbDatabase::clear() destructs the database and reconstructs it using this constructor, the database's logger becomes nullptr after clear(). Any subsequent database operation that attempts to log (which calls getLogger()) will find logger_ is nullptr and terminate the program. To prevent this, we should initialize logger_ to utl::Logger::defaultLogger() during reconstruction.
logger_ = utl::Logger::defaultLogger();
alignment_marker_rule_tbl_ = new dbTable<_dbAlignmentMarkerRule>(|
Can you just do and avoid having two copies of the same. I haven't fully verified this is actually equivalent but I hope it would be. |
Summary
Fixes a latent bug in
_dbDatabase::_dbDatabase(_dbDatabase*, int id)— the placement-new constructor used bydbDatabase::clear()— that only allocated a subset of the tables that~_dbDatabasedeletes. Afterclear(), the remaining table pointers held dangling values from the just-destructed object, and any iterator built against them (chip_inst_itr_,chip_region_inst_itr_,chip_conn_itr_,chip_bump_inst_itr_,chip_net_itr_,unfolded_region_itr_,unfolded_bump_itr_) dereferenced uninitialized memory.Type of Change
Impact
dbDatabase::clear()is now safe to call: after the destructor runs and the placement-new constructor reconstructs the object, all tables the destructor expects are allocated, and all iterator pointers reference live tables.Verification
./etc/Build.sh).