Skip to content

Fix high-severity Coverity issues#242

Merged
derobins merged 6 commits intodevelopfrom
derobins/coverity_high
Mar 30, 2026
Merged

Fix high-severity Coverity issues#242
derobins merged 6 commits intodevelopfrom
derobins/coverity_high

Conversation

@derobins
Copy link
Copy Markdown
Collaborator

@derobins derobins commented Mar 30, 2026

Fixes a couple of high-severity issues identified by Coverity Scan

  • Marks use-after-move as intentional in the file descriptor tests
  • Fully initialize a struct in the stats code
  • Ensure a socket is cleaned up on errors in StatsServer::threadFn()
  • Check the return value from poll(2) in stats.cpp

Part of AIHIPFILE-161

Coverity complains about using moved hipFile descriptors in
some tests that check for behavior after destruction. These
tests could be improved, but for now we'll mark the behavior
as intentional (as we do for clang).
Coverity complains about the msghdr struct not having the
msg_flags field set, so it will contain garbage.

* Explicitly set the msg_flags field to 0
* Defensively initialize the msghdr structs using {}
Coverity complains about an unclosed socket in stats.cpp under
certain error conditions. Fixed by setting a common exit point
where the socket is always closed if it's not -1.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Addresses high-severity Coverity findings in tests and stats IPC by adding explicit suppressions/initialization and improving error-path cleanup.

Changes:

  • Adds Coverity “use-after-move” suppressions in file descriptor move tests.
  • Value-initializes msghdr / related variables in fd-passing helpers to avoid partially-initialized structs.
  • Ensures StatsServer::threadFn() closes its server socket on early errors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
test/amd_detail/file-descriptor.cpp Marks intentional post-move inspection in tests for Coverity.
src/amd_detail/stats.cpp Fully initializes message header structs and adds error-path socket cleanup in the stats server.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* controlMsg union was not initialized
* cmsgp switched from `= nullptr` to `{}` for uniformity
* Continue when -1 && errno == EINTR
* Break when -1 otherwise
* Continue when 0
EXPECT_CALL(msys, mmap).WillOnce(testing::Return(&buff));
EXPECT_CALL(msys, munmap);
EXPECT_CALL(msys, close).Times(2);
EXPECT_CALL(msys, close).Times(3);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Have to bump this because now we are calling one more close() through the mock

@derobins derobins merged commit 233994e into develop Mar 30, 2026
39 checks passed
@derobins derobins deleted the derobins/coverity_high branch March 30, 2026 23:30
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.

4 participants