Skip to content

fix: clear[] crashed after a fire whose front had stopped - #194

Open
yanissrairi wants to merge 2 commits into
forefireAPI:devfrom
yanissrairi:fix/timetable-dangling-head
Open

yanissrairi wants to merge 2 commits into
forefireAPI:devfrom
yanissrairi:fix/timetable-dangling-head

Conversation

@yanissrairi

Copy link
Copy Markdown
Contributor

When a fire's front stops everywhere (e.g. an ignition in non-burnable fuel), the next clear[] segfaults.

getUpcomingEvent took the last event out but left head pointing at it. The stopped node's event has an infinite time, so insert() deleted it, and clear() deleted it again through head. The fix sets head = nullptr in that branch.

Reproduction, from tests/runff:

include[params.ff]
loadData[data.nc;2025-02-10T17:35:54Z]
startFire[loc=(38305.0,28205.0,0);t=0]
goTo[t=600]
clear[]
loadData[data.nc;2025-02-10T17:35:54Z]
startFire[loc=(35881.873264425,28699.674854985,0);t=0]
goTo[t=600]

Added tests/unit/test_timetable.cpp, which crashes without the fix. ctest and runff pass.

When the last event is taken out of the TimeTable, getUpcomingEvent left
head pointing at it. If that event then had an infinite time (its node
stopped), insert() deleted it and head dangled, so clear() deleted it a
second time. dropAtomEvents could likewise delete the event being processed.
@yanissrairi
yanissrairi force-pushed the fix/timetable-dangling-head branch from 545bbef to 1b011b7 Compare October 5, 2026 12:09
@filippi

filippi commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

thanks @yanissrairi the clear[] hasn't been much tested yet. My problem is testing it into a coupled fire/atmospher context with MPI and Fortan bindings, which i have no time to do yet.. very sorry. I'll be back on these around Oct 20.

# Conflicts:
#	CHANGELOG.md

@antonio-leblanc antonio-leblanc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yanissrairi! Reproduced the crash on dev and the fix here; real_case output is byte-identical before and after. I merged dev in to fix the CHANGELOG conflict.

@antonio-leblanc

Copy link
Copy Markdown
Collaborator

Tested the coupled case with this branch vs dev:

  • Ubuntu 24.04 (WSL2), GCC/gfortran 13.3, Open MPI 4.1.6
  • Meso-NH 6.0.1 (Zenodo release), built as LXgfortran-R8I4-MPIAUTO-O2
  • ForeFire built with -DFOREFIRE_ENABLE_MPI=ON, linked as $SRC_MESONH/exe/libForeFire.so: dev at f4b3fd8, this PR at 1b011b7
  • Case tests/mnh_real_nested, mpiexec -np 4, with LHORELAX_SVC1R3, NLBLX and NLBLY removed from the two .des
  • 4 runs: dev, PR, dev, PR

Result: 107 of 119 output files (ForeFire/Outputs, MODEL1, MODEL2, RUN12.*.FIRE.*.nc) are bit-identical across all 4 runs. The other 12 (the air_density dumps and the NetCDF history timestamp) also differ between the two dev runs, so it's run-to-run noise, not this change.

This branch has not been deployed

No deployments
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.

3 participants