Skip to content

Commit 8460a37

Browse files
committed
Avoid memory overrun/underrun in reserve_locally_used_opins.
Signed-off-by: Keith Rothman <[email protected]>
1 parent f8e863f commit 8460a37

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

vpr/src/base/read_route.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ bool read_route(const char* route_file, const t_router_opts& router_opts, bool v
109109
fp.close();
110110

111111
/*Correctly set up the clb opins*/
112+
reserve_locally_used_opins(router_opts.initial_pres_fac,
113+
router_opts.acc_fac, false);
112114
recompute_occupancy_from_scratch();
113115

114116
/* Note: This pres_fac is not necessarily correct since it isn't the first routing iteration*/

vpr/src/route/check_route.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ void recompute_occupancy_from_scratch() {
560560
/* Will always be 0 for pads or SINK classes. */
561561
for (ipin = 0; ipin < num_local_opins; ipin++) {
562562
inode = route_ctx.clb_opins_used_locally[blk_id][iclass][ipin];
563+
VTR_ASSERT(inode >= 0 && inode < (ssize_t)device_ctx.rr_nodes.size());
563564
route_ctx.rr_node_route_inf[inode].set_occ(route_ctx.rr_node_route_inf[inode].occ() + 1);
564565
}
565566
}

vpr/src/route/route_common.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,7 @@ void reserve_locally_used_opins(float pres_fac, float acc_fac, bool rip_up_local
16461646
/* Always 0 for pads and for RECEIVER (IPIN) classes */
16471647
for (ipin = 0; ipin < num_local_opin; ipin++) {
16481648
inode = route_ctx.clb_opins_used_locally[blk_id][iclass][ipin];
1649+
VTR_ASSERT(inode >= 0 && inode < (ssize_t)device_ctx.rr_nodes.size());
16491650
adjust_one_rr_occ_and_apcost(inode, -1, pres_fac, acc_fac);
16501651
}
16511652
}

0 commit comments

Comments
 (0)