You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory leak in OperatorEXXPW when ik > nks triggers early return #8022
get_exx_potential and get_exx_stress_potential in source/source_pw/module_pwdft/op_pw_exx_pot.cpp allocate a CPU buffer (pot_cpu = new Real[npw]) but can return early or throw before the matching delete[], leaking the allocation.
Affected locations
Function
new line
Leaking exit
delete[] line
get_exx_potential
37
return at line 52
225
get_exx_potential
37
throw at line 213
225
get_exx_stress_potential
250
throw at line 403
415
Early return:if (ik > nks) { return; } at line 52 leaks pot_cpu every time it triggers.
GPU exception path: If cudaHostRegister fails, the throw at lines 213 / 403 leaks pot_cpu and also leaves the pointer registered.
Trigger frequency: Any EXX calculation where ik > nks (e.g., certain k-parallel or restart paths). If this happens once per SCF step per k-point, the leak is small but unbounded over long runs.
Suggested fix
Move the allocation after the early-return guard, or wrap pot_cpu in a std::unique_ptr<Real[]>:
### Expected behavior
_No response_
### To Reproduce
_No response_
### Environment
_No response_
### Additional Context
_No response_
### Task list for Issue attackers (only for developers)
- [ ] Verify the issue is not a duplicate.
- [ ] Describe the bug.
- [ ] Steps to reproduce.
- [ ] Expected behavior.
- [ ] Error message.
- [ ] Environment details.
- [ ] Additional context.
- [ ] Assign a priority level (low, medium, high, urgent).
- [ ] Assign the issue to a team member.
- [ ] Label the issue with relevant tags.
- [ ] Identify possible related issues.
- [ ] Create a unit test or automated test to reproduce the bug (if applicable).
- [ ] Fix the bug.
- [ ] Test the fix.
- [ ] Update documentation (if necessary).
- [ ] Close the issue and inform the reporter (if applicable).
Activity
Fix(pw): release EXX potential buffers on all exit paths (#8022) (#8037)