Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/amd_detail/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ StatsServer::StatsServer()
StatsServer::~StatsServer()
{
if (m_thread.joinable()) {
uint64_t i{1};
write(m_efd.get(), &i, sizeof(i));
uint64_t i{1};
[[maybe_unused]] ssize_t nbytes;

nbytes = write(m_efd.get(), &i, sizeof(i));
m_thread.join();
Comment on lines +111 to 115
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

write() is used to wake the polling thread so the destructor can join(). If this write() fails (e.g., returns -1 on EINTR), the polling thread may never be notified and the destructor can block indefinitely in join(). Since you now capture the return value, it’d be safer to retry on EINTR and handle hard failures (e.g., by also making threadFn() break on POLLERR/POLLNVAL for the eventfd, or otherwise ensuring the thread is guaranteed to exit).

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@zbyrne Is this valid? Does this need a real fix?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I vote to fix it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, sounds valid. Shame we aren't using C++20 with jthreads and stop_tokens

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I'm going to close this PR then while @zbyrne implements a real fix

}
}
Expand Down
Loading