Skip to content

Conversation

@openroad-ci
Copy link
Collaborator

Addresses an issue where utl::OutStreamHandler could cause a crash (std::terminate) if a file flush or rename failed during destruction (e.g., due to ENOSPC).

  • Added explicit close() methods to OutStreamHandler, InStreamHandler, and FileHandler to allow users to handle closure errors explicitly.
  • Updated destructors to be exception-safe by catching potential errors during implicit closure.
  • Added diagnostic logging to std::cerr in destructors to report closure failures that would otherwise be suppressed.

Fixes #9252

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 effectively addresses the risk of exceptions being thrown from destructors in file handling classes by introducing explicit close() methods and ensuring destructors are exception-safe. This improves robustness and provides users a way to handle file closure errors explicitly. My review includes one high-severity suggestion for FileHandler::close() to ensure it properly reports errors instead of failing silently, which aligns with the overall goal of this pull request.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Addresses an issue where utl::OutStreamHandler could cause a crash
(std::terminate) if a file flush or rename failed during destruction
(e.g., due to ENOSPC).

- Added explicit close() methods to OutStreamHandler, InStreamHandler,
  and FileHandler to allow users to handle closure errors explicitly.
- Updated destructors to be exception-safe by catching potential errors
  during implicit closure.
- Added diagnostic logging to std::cerr in destructors to report
  closure failures that would otherwise be suppressed.

Fixes The-OpenROAD-Project#9252

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty maliberty enabled auto-merge January 14, 2026 19:11
@maliberty maliberty merged commit bffc9a6 into The-OpenROAD-Project:master Jan 14, 2026
13 checks passed
@maliberty maliberty deleted the utl-file-dtor-catch branch January 14, 2026 19:51
Copy link
Collaborator

@oharboe oharboe left a comment

Choose a reason for hiding this comment

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

Nice! Ideally the close() is called from user-code so that the exception is propagated from user-code and not logged and silenced.

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.

Refactor utl::OutStreamHandler to handle I/O errors gracefully (prevent crash on Disk Full)

3 participants