Bug: SIGSEGV when DEBUG is enabled for the volume routine (NATCRS)
Enabling the DEBUG keyword so that the volume routine is traced crashes FVS with a
segmentation fault during the run (exit 139). It reproduces with the repo's default
gfortran build (bin/makefile) for any variant and any stand that computes volume.
Normal (non-DEBUG) runs are unaffected.
Root cause. In vvolume/fvsvol.f, near the end of ENTRY NATCRS:
IF(DEBUG)WRITE(JOSTND,*)' IN FVSVOL D, VN, VM, VMAX, BBFV = ',
& D, VN, VM, VMAX, BBFV
VN and VM are dummy arguments of ENTRY OCFVOL, not of ENTRY NATCRS. When
NATCRS is the active entry they are unassociated; the list-directed write then
dereferences a null pointer. The label and operands match the OCFVOL trace a few
lines down (where VN/VM are valid), so it appears to be a copy/paste into the
NATCRS fall-through path.
Backtrace (top frames):
get_float_string (libgfortran) <- EXC_BAD_ACCESS, address 0x0
list_formatted_write_scalar
master.0.fvsvol_ fvsvol.f (IF(DEBUG)WRITE in ENTRY NATCRS)
natcrs_ fvsvol.f
vols_ -> update_ -> gradd_ -> tregro_ -> fvs_
Reproduce: any stand with NUMCYCLE >= 1 plus a DEBUG keyword that turns
debugging on while volume is computed.
Fix: trace NATCRS's own assigned outputs (TCF,MCF,SCF) instead of the
unassociated VN,VM. PR attached. The change is confined to the IF(DEBUG) path and
does not alter computed model output (verified byte-identical before/after).
Bug: SIGSEGV when DEBUG is enabled for the volume routine (NATCRS)
Enabling the
DEBUGkeyword so that the volume routine is traced crashes FVS with asegmentation fault during the run (exit 139). It reproduces with the repo's default
gfortranbuild (bin/makefile) for any variant and any stand that computes volume.Normal (non-
DEBUG) runs are unaffected.Root cause. In
vvolume/fvsvol.f, near the end ofENTRY NATCRS:VNandVMare dummy arguments ofENTRY OCFVOL, not ofENTRY NATCRS. WhenNATCRSis the active entry they are unassociated; the list-directed write thendereferences a null pointer. The label and operands match the
OCFVOLtrace a fewlines down (where
VN/VMare valid), so it appears to be a copy/paste into theNATCRSfall-through path.Backtrace (top frames):
Reproduce: any stand with
NUMCYCLE >= 1plus aDEBUGkeyword that turnsdebugging on while volume is computed.
Fix: trace
NATCRS's own assigned outputs (TCF,MCF,SCF) instead of theunassociated
VN,VM. PR attached. The change is confined to theIF(DEBUG)path anddoes not alter computed model output (verified byte-identical before/after).