Fix uninitialized tc_curr causing FIDEAL debug crash - #8647
Open
mt5555 wants to merge 1 commit into
Open
Conversation
The energy diagnostic state fields (tc_curr, tc_init, tc_mnst, tc_prev) are allocated with tc_curr set to an Infinity sentinel value, and are normally zeroed out by co2_diags_init(). However, phys_init() returns early for adiabatic/ideal physics configurations (e.g. the FIDEAL compset) before reaching the co2_diags_init() call, leaving tc_curr at Infinity for the entire run. In debug builds, this trips the shr_assert_in_domain check on state%tc_curr and crashes the run with a segmentation fault during cime_init. Move the co2_diags_init() call to before the adiabatic/ideal_phys early return so these fields are always initialized, and remove the now-redundant duplicate call further down. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fix a crash in FIDEAL debug builds caused by an uninitialized energy diagnostic state field.
Fixes #5294
Description
The energy diagnostic state fields (
tc_curr,tc_init,tc_mnst,tc_prev) are allocated withtc_currset to anInfinitysentinel value, and are normally zeroed out byco2_diags_init(). However,phys_init()returns early for adiabatic/ideal physics configurations (e.g. theFIDEALcompset) before reaching theco2_diags_init()call, leavingtc_curratInfinityfor the entire run.In debug builds, this trips the
shr_assert_in_domaincheck onstate%tc_currand crashes the run with a segmentation fault duringcime_init.This PR moves the
co2_diags_init()call to before theadiabatic/ideal_physearly return inphys_init()so these fields are always initialized, and removes the now-redundant duplicate call further down.Testing
Tested on Chrysalis (LCRC) with
ERP_D_Ld3.ne4pg2_ne4pg2.FIDEAL.chrysalis_gnu.allactive-pioroot1andERP_D_Ld3.ne4pg2_ne4pg2.FIDEAL.chrysalis_intel.allactive-pioroot1(both now PASS; previously failed with a segfault at RUN). Also verifiedERP_Ld3.ne4pg2_ne4pg2.FIDEAL.chrysalis_intel.allactive-pioroot1 -c -b masterpasses and matches themasterbaseline bit-for-bit, confirming no change in non-debug model behavior.