Skip to content

Fix Invalid memory accesses - #3

Closed
manodeep wants to merge 2 commits into
masterfrom
2029-invalid-memory-access
Closed

manodeep wants to merge 2 commits into
masterfrom
2029-invalid-memory-access

Conversation

@manodeep

@manodeep manodeep commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fix for upstream issue 2029. This fix is required for upgrading OpenMPI from v4 to v5

I have run with the two patches in OM3 and the patches i) fix the crashes, and ii) produce bitwise identical results. Anton has done the same separately with the tests and found the same two characteristics

Both patches are generated by Claude Opus 5. The first patch looked reasonable (when I first used it back in Sep/Oct), but even back then, I did not dig into whether the second commit was the best possible patch other than the observation that it completely solved the runtime OM3 crashes.

@anton-seaice @minghangli-uni How do we want to proceed with i) reviewing this PR and ii) sending to upstream?

@anton-seaice

Copy link
Copy Markdown
Collaborator

send it upstream please, i can try to email NCAR ppl direct if we don't get any response.

just standard review thoughts from me:

  • make sure the code comments make sense in a persistent sense, not just for this change
  • a minimal reproducible example makes the case stronger to others that it works

@manodeep

Copy link
Copy Markdown
Collaborator Author

send it upstream please, i can try to email NCAR ppl direct if we don't get any response.

Alright I will switch out the target to the upstream "main"

just standard review thoughts from me:

* make sure the code comments make sense in a persistent sense, not just for this change

Hmm - let me re-read and check that that condition holds

* a minimal reproducible example makes the case stronger to others that it works

I have asked Claude to come up with one 😬

@manodeep
manodeep force-pushed the 2029-invalid-memory-access branch from 14256bb to 62f4064 Compare November 27, 2026 09:48
@manodeep

manodeep commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

I have now fixed the inline comments in the first patch; the second one seemed fine to me.

Claude did produce a reproducer and a shell script that uses the address sanitizer to detect the bug addressed by the second commit. I have tested these on Gadi and it detect the crashes in unpatched, and the passes in the patched. I also tried to trick it by passing two different unpatched PIO libraries and the script correctly noted crashes for both PIO libraries.

[~/temp/test-pio-invalid-memory-access @gadi-login-01]$ /bin/bash run_repro.sh /g/data/vk83/prerelease/apps/spack/1.1/release/linux-x86_64_v4/paral
lelio-2.6.8-gqhaucugrehnuoufslfk6ddebrv6xfef  /g/data/vk83/apps/spack/0.22/release/linux-rocky8-x86_64/intel-2021.10.0/parallelio-2.6.2-x2jbzjmskgr4qm7ebtamwcp3mela2oph
unpatched PIO: /g/data/vk83/apps/spack/0.22/release/linux-rocky8-x86_64/intel-2021.10.0/parallelio-2.6.2-x2jbzjmskgr4qm7ebtamwcp3mela2oph/lib  (from /g/data/vk83/apps/spack/0.22/release/linux-rocky8-x86_64/intel-2021.10.0/parallelio-2.6.2-x2jbzjmskgr4qm7ebtamwcp3mela2oph; PnetCDF: no)
patched PIO: /g/data/vk83/prerelease/apps/spack/1.1/release/linux-x86_64_v4/parallelio-2.6.8-gqhaucugrehnuoufslfk6ddebrv6xfef/lib  (from /g/data/vk83/prerelease/apps/spack/1.1/release/linux-x86_64_v4/parallelio-2.6.8-gqhaucugrehnuoufslfk6ddebrv6xfef; PnetCDF: yes)
skipping pnetcdf: not every PIO was built with PnetCDF
WARNING: unpatched libpioc.so was built with /apps/openmpi/4.1.7/lib/libmpi.so.40, but mpicc links /apps/openmpi/5.0.8/lib/libmpi.so.40; load the matching MPI module.

case                       unpatched                patched                 
write netcdf               SIGSEGV                  PASS                    
read netcdf                SIGSEGV                  PASS                    
dupread netcdf, plain      PASS                     PASS                    
dupread netcdf, ASan       MPI_Send overread        PASS
[~/temp/test-pio-invalid-memory-access @gadi-login-01]$ ml
Currently Loaded Modulefiles:
 1) pbs                            6) python3-as-python                  11) access-generic-tracers/2026.09.000-e3zb3ez  
 2) intel-mkl/2023.2.0             7) netcdf/4.9.2                       12) access-mom6/2026.05.003-ld7hklz             
 3) python3/3.12.1                 8) access3-share/2026.03.002-eale5gm  13) access-ww3/2026.03.001-bjzidie              
 4) intel-compiler-llvm/2025.2.0   9) access-cice/CICE6.6.3-2-huasrvo    14) access3/2026.03.002-26wbxup                 
 5) openmpi/5.0.8                 10) access-mocsy/2025.07.002-saj7rvh   15) access-om3/2026.05.004                       

run_repro.sh
pio_repro.c

If this looks reasonable, I will close this PR and open the one to upstream.

Edit: Claude also created this file for the tests
0001-Add-test_darray_subset-a-regression-test-for-two-inv.patch

@anton-seaice

Copy link
Copy Markdown
Collaborator

Looks ok to me, the examples / tests are quite long but just make the PR upstream and see what the say

@manodeep

Copy link
Copy Markdown
Collaborator Author

Thanks Anton. PR opened to upstream

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.

2 participants