Skip to content

fix: guard parseBusName against non-numeric bus subscripts#339

Merged
maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:sta_handle_funny_defs
Apr 6, 2026
Merged

fix: guard parseBusName against non-numeric bus subscripts#339
maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:sta_handle_funny_defs

Conversation

@openroad-ci

Copy link
Copy Markdown
Member

Problem:
Reading a DEF with port names containing non-numeric bracket subscripts (e.g., kv_write[3][write_en]) crashes with a segfault. parseBusName uses rfind('[') to find the last left bracket, then calls std::stoi on the content. For kv_write[3][write_en], rfind finds the [ before write_en, and stoi("write_en]") throws an unhandled std::invalid_argument which terminates the process.

This occurs when externally-produced DEF files use multi-level bracket names where the innermost subscript is a field name rather than a numeric bus index.

Fix:
Add an isdigit check on the first character after [ before calling stoi in both parseBusName overloads. Non-numeric subscripts like [write_en] are treated as non-bus names (is_bus = false), while ports with numeric trailing subscripts like kv_write[3][ write_entry][4] continue to parse and group correctly as bus kv_write[3][write_entry] with index 4.

Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
@maliberty maliberty merged commit e4338cf into The-OpenROAD-Project:master Apr 6, 2026
7 checks passed
@openroad-ci openroad-ci deleted the sta_handle_funny_defs branch April 6, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants