Affected version: develop (commit ae45a18, 2026-05-06, "Fix memory leak in block_dimension_routines.inc"). The v8.4.0 tag is NOT affected — building from it works.
Summary
Both cores crash with SIGSEGV during initialization, immediately after reading dimensions:
... Assigning remaining dimensions from definitions in Registry.xml ...
nVertLevels = 55 (config_nvertlevels)
...
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
#3 __init_atm_core_interface_MOD_init_atm_setup_derived_dimensions
at ./inc/block_dimension_routines.inc:243
#4 __mpas_block_creator_MOD_mpas_block_creator_finalize_block_phase2 (mpas_block_creator.F:1275)
#5 __mpas_bootstrapping_MOD_mpas_bootstrap_framework_phase2 (mpas_bootstrapping.F:675)
Root cause
Commit ae45a18 added deallocate() after mpas_pool_add_dimension(...) in parse_dimensions_from_registry (src/tools/registry/gen_inc.c). For dimensions not yet in the pool, the generated setup_derived_dimensions now allocates a local pointer, adds it to the pool, and deallocates it (→ the pointer becomes disassociated/NULL). The subsequently generated derived-dimension code then reads that freed pointer, e.g.:
nVertLevelsP1 = nVertLevels + 1 ! nVertLevels was just deallocate()d → NULL deref
So a base dimension is freed and then dereferenced by a derived-dimension expression in the same routine.
Reproduction & scope
Deterministic; reproduced with gfortran 12 and 13, at -O0 and -O3, in a clean env (env -i), with multiple meshes (x1.10242, x1.40962). → independent of environment, compiler, and optimization.
The deallocate(%s) lines are present in current develop src/tools/registry/gen_inc.c (the generated derived-dim code dereferences those dimensions).
Workaround
Building from the v8.4.0 tag (which predates ae45a18) compiles and runs init_atmosphere/atmosphere with no such crash.
Suggested fix
Don't free dimension pointers that are later referenced by derived-dimension expressions. Options: defer the deallocate until after all derived dimensions are computed; re-mpas_pool_get_dimension the operands before using them; or compute derived dimensions from the namelist/config values rather than the freed locals.
(Disclairmer, I do not code on C/Fortran. After a couple of days struggling with the model, I asked the AI to assist me and this is what it found)
Affected version: develop (commit ae45a18, 2026-05-06, "Fix memory leak in block_dimension_routines.inc"). The v8.4.0 tag is NOT affected — building from it works.
Summary
Both cores crash with SIGSEGV during initialization, immediately after reading dimensions:
... Assigning remaining dimensions from definitions in Registry.xml ...
nVertLevels = 55 (config_nvertlevels)
...
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
#3 __init_atm_core_interface_MOD_init_atm_setup_derived_dimensions
at ./inc/block_dimension_routines.inc:243
#4 __mpas_block_creator_MOD_mpas_block_creator_finalize_block_phase2 (mpas_block_creator.F:1275)
#5 __mpas_bootstrapping_MOD_mpas_bootstrap_framework_phase2 (mpas_bootstrapping.F:675)
Root cause
Commit ae45a18 added deallocate() after mpas_pool_add_dimension(...) in parse_dimensions_from_registry (src/tools/registry/gen_inc.c). For dimensions not yet in the pool, the generated setup_derived_dimensions now allocates a local pointer, adds it to the pool, and deallocates it (→ the pointer becomes disassociated/NULL). The subsequently generated derived-dimension code then reads that freed pointer, e.g.:
nVertLevelsP1 = nVertLevels + 1 ! nVertLevels was just deallocate()d → NULL deref
So a base dimension is freed and then dereferenced by a derived-dimension expression in the same routine.
Reproduction & scope
Deterministic; reproduced with gfortran 12 and 13, at -O0 and -O3, in a clean env (env -i), with multiple meshes (x1.10242, x1.40962). → independent of environment, compiler, and optimization.
The deallocate(%s) lines are present in current develop src/tools/registry/gen_inc.c (the generated derived-dim code dereferences those dimensions).
Workaround
Building from the v8.4.0 tag (which predates ae45a18) compiles and runs init_atmosphere/atmosphere with no such crash.
Suggested fix
Don't free dimension pointers that are later referenced by derived-dimension expressions. Options: defer the deallocate until after all derived dimensions are computed; re-mpas_pool_get_dimension the operands before using them; or compute derived dimensions from the namelist/config values rather than the freed locals.
(Disclairmer, I do not code on C/Fortran. After a couple of days struggling with the model, I asked the AI to assist me and this is what it found)