hotfix - safeguard invalid scalar indices to prevent segmentation faults during LBC/IC generation#263
Open
guoqing-noaa wants to merge 1 commit into
Open
Conversation
…g LBC/IC genereation
clark-evans
approved these changes
Jun 21, 2026
dustinswales
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@keenan and I got the same lbc task crash on Hera recently. All lbc files were generated correctly but the task failed due to
segmentation fault occurred:It looks similar to the behavior we met before when running the model where the executable just could not terminate correctly.
I tried a debug build and identified that the crash happened at line 8577 of
mpas_init_atm_cases.F:and lines 8577-8581 read as follows:
So it suggested a
-1ofindex_nccaused the crash.In
src/core_init_atmosphere/Registry.xml, we can find that whenlbc_hydrometeors_gfsis true whilelbc_hydrometeors_rrfsis false, we only havelbc_qv, lbc_qc, lbc_qr, lbc_qi, lbc_qs, lbc_qg, do not havelbc_nc/ni,..... Hence we will of course get-1for their indexes (index_nc, ect).This PR provides a hotfix by checking
if (index_nc > 0)before settingscalars(index_nc,:,iCell) = 0._RKIND.Similar safeguards are applied to IC generation where
index_nwfaandindex_nifaare only available for specific packages.I don't have a full answer to why this only crashes on Hera but not on other machines.
Different machines have different memory/heap layout, the out-of-bounds address may still be within a valid memory page, so no SIGSEGV occurs and the program finishes "successfully".
Mandatory Questions
Reviews