Skip to content

Fix release (and double release) of mu2e PCIe device by destructors f…#130

Merged
rrivera747 merged 4 commits intodevelopfrom
rrivera/fixReleaseOfDeviceByDestructors
Mar 17, 2026
Merged

Fix release (and double release) of mu2e PCIe device by destructors f…#130
rrivera747 merged 4 commits intodevelopfrom
rrivera/fixReleaseOfDeviceByDestructors

Conversation

@rrivera747
Copy link
Copy Markdown
Contributor

…rom class hierarchy of CFO/DTC

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

This PR fixes the release (and double release) of the mu2e PCIe device by moving cleanup logic into mu2edev::close() and calling it from the mu2edev destructor, removing redundant device_.close() calls from derived class destructors. It also adds munmap cleanup, improves version mismatch error handling for CFO, and adds diagnostic logging.

Changes:

  • Moved device_.close() from CFOandDTC_Registers and CFO_Registers destructors into mu2edev::~mu2edev(), and enhanced close() to properly munmap before closing the file descriptor
  • Added try/catch around std::stoul for CFO version parsing (matching existing DTC pattern), with device index in error messages
  • Initialized devfd_ to -1 and fixed the sentinel value check/reset from 0 to -1

Reviewed changes

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

Show a summary per file
File Description
dtcInterfaceLib/mu2edev.h Initialize devfd_ to -1
dtcInterfaceLib/mu2edev.cpp Add close() call in destructor, add munmap in close(), use -1 sentinel for devfd_, add logging
dtcInterfaceLib/CFOandDTC_Registers.cpp Remove device_.close() from destructor (now handled by mu2edev)
cfoInterfaceLib/CFO_Registers.cpp Remove device_.close() from destructor; add robust version parsing with try/catch
dtcInterfaceLib/DTC_Registers.cpp Add device index to version mismatch error messages, bump destructor log level

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

Comment thread dtcInterfaceLib/mu2edev.cpp Outdated
Comment thread dtcInterfaceLib/mu2edev.cpp Outdated
rrivera747 and others added 2 commits March 16, 2026 19:53
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@rrivera747 rrivera747 merged commit b253b97 into develop Mar 17, 2026
9 of 11 checks passed
@rrivera747 rrivera747 deleted the rrivera/fixReleaseOfDeviceByDestructors branch March 17, 2026 14:57
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