Fix loc_violations used uninitialized in MPI_Allreduce#1186
Fix loc_violations used uninitialized in MPI_Allreduce#1186sbryngelson wants to merge 2 commits intoMFlowCode:masterfrom
Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the loc_violations variable is used in an MPI_Allreduce operation without being initialized, causing non-violating ranks to contribute undefined values to the global sum.
Changes:
- Initialize
loc_violationsto 0 at declaration to prevent uninitialized memory from being used in MPI reduction operations
loc_violations is never set to 0 before the conditional that may or may not assign it. Non-violating ranks sum garbage in the reduction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2d65b67 to
ad5925e
Compare
Initializing a local variable in its declaration gives it the SAVE attribute in Fortran, meaning it would not reset to zero on subsequent calls. Move the initialization to an executable assignment so the variable is properly zeroed each time the subroutine is entered. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1186 +/- ##
=======================================
Coverage 44.05% 44.05%
=======================================
Files 70 70
Lines 20498 20499 +1
Branches 1990 1990
=======================================
+ Hits 9030 9031 +1
Misses 10329 10329
Partials 1139 1139 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Severity: HIGH — non-violating MPI ranks sum garbage in the reduction.
File:
src/pre_process/m_data_output.fpp, line 479loc_violationsis declared but never initialized to 0. It is only assigned inside a conditional (if (mod(...) > 0)), so ranks that don't enter the conditional contribute uninitialized values to the subsequentMPI_Allreducesum.Before
After
Why this went undetected
Ranks that happen to have zero-initialized stack memory would produce correct results. The bug is non-deterministic and depends on memory state.
Test plan
🤖 Generated with Claude Code
Fixes #1206