Skip to content

Commit b2317a3

Browse files
authored
Merge pull request #9048 from The-OpenROAD-Project-staging/secure-copy-drivers-pin-set
rsz: Fixed a memory corruption issue by copying `PinSet* drivers`
2 parents fbbbb19 + 2022ca8 commit b2317a3

File tree

2 files changed

+46
-29
lines changed

2 files changed

+46
-29
lines changed

src/dbSta/include/db_sta/dbNetwork.hh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,26 @@ class dbNetwork : public ConcreteNetwork
251251
Instance* instance(const Pin* pin) const override;
252252
Net* net(const Pin* pin) const override;
253253
void net(const Pin* pin, dbNet*& db_net, dbModNet*& db_modnet) const;
254+
255+
///
256+
/// Get a dbNet connected to the input pin.
257+
/// - If both dbNet and dbModNet are connected to the input pin,
258+
/// this function returns the dbNet.
259+
/// - NOTE: If only dbModNet is connected to the input pin, this
260+
/// function returns nullptr. If you need to get the dbNet corresponding to
261+
/// the dbModNet, use findFlatDbNet() instead.
262+
///
254263
dbNet* flatNet(const Pin* pin) const;
264+
265+
///
266+
/// Get a dbModNet connected to the input pin.
267+
/// - If both dbNet and dbModNet are connected to the input pin,
268+
/// this function returns the dbModNet.
269+
/// - If only dbNet is connected to the input pin, this function returns
270+
/// nullptr.
271+
///
255272
dbModNet* hierNet(const Pin* pin) const;
273+
256274
dbITerm* flatPin(const Pin* pin) const;
257275
dbModITerm* hierPin(const Pin* pin) const;
258276
dbBlock* getBlockOf(const Pin* pin) const;

src/rsz/src/RepairDesign.cc

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -402,28 +402,33 @@ void RepairDesign::repairDesign(
402402
}
403403
}
404404
if (slew_viol) {
405-
PinSet* drivers = network_->drivers(vertex->pin());
406-
for (const Pin* drvr_pin : *drivers) {
407-
debugPrint(logger_,
408-
RSZ,
409-
"repair_design",
410-
2,
411-
"last pass: drvr {} has slew {} vs. limit {}",
412-
sdc_network_->pathName(drvr_pin),
413-
delayAsString(actual, this, 3),
414-
delayAsString(limit, this, 3));
415-
repairDriver(graph_->pinDrvrVertex(drvr_pin),
416-
true /* check_slew */,
417-
false /* check_cap */,
418-
false /* check_fanout */,
419-
0 /* max_length */,
420-
true /* resize_driver */,
421-
corner,
422-
repaired_net_count2,
423-
slew_violations2,
424-
cap_violations,
425-
fanout_violations,
426-
length_violations);
405+
PinSet* drivers_ptr = network_->drivers(vertex->pin());
406+
if (drivers_ptr) {
407+
// Copy PinSet because repairDriver() can invalidate the
408+
// drivers_ptr by invalidating net_drvr_pin_map_ cache.
409+
PinSet drivers = *drivers_ptr;
410+
for (const Pin* drvr_pin : drivers) {
411+
debugPrint(logger_,
412+
RSZ,
413+
"repair_design",
414+
2,
415+
"last pass: drvr {} has slew {} vs. limit {}",
416+
sdc_network_->pathName(drvr_pin),
417+
delayAsString(actual, this, 3),
418+
delayAsString(limit, this, 3));
419+
repairDriver(graph_->pinDrvrVertex(drvr_pin),
420+
true /* check_slew */,
421+
false /* check_cap */,
422+
false /* check_fanout */,
423+
0 /* max_length */,
424+
true /* resize_driver */,
425+
corner,
426+
repaired_net_count2,
427+
slew_violations2,
428+
cap_violations,
429+
fanout_violations,
430+
length_violations);
431+
}
427432
}
428433
}
429434
}
@@ -1014,13 +1019,7 @@ void RepairDesign::repairDriver(Vertex* drvr,
10141019
int& length_violations)
10151020
{
10161021
Pin* drvr_pin = drvr->pin();
1017-
// hier fix
1018-
// clang-format off
1019-
Net* net = network_->isTopLevelPort(drvr_pin)
1020-
? db_network_->dbToSta(
1021-
db_network_->flatNet(network_->term(drvr_pin)))
1022-
: db_network_->dbToSta(db_network_->flatNet(drvr_pin));
1023-
// clang-format on
1022+
Net* net = db_network_->findFlatNet(drvr_pin);
10241023
if (!net) {
10251024
return;
10261025
}

0 commit comments

Comments
 (0)