Cloudy & Associates

Skip to content

Fix bug in 'save species bands'

Chatzikos, Marios requested to merge spec_lines into master

User Swayam Panda reported that using the 'save species bands' command more than once in an input deck leads to a segmentation fault. I have been able to reproduce the bug.

What causes the bug is a misconception about C++ vector iterators. When storing the data entered in the commands, the file that holds the bands is read in, and its data stored in static vector for the bands file objects by growing the vector (with push_back()). An iterator to that memory location is returned to, and stored by the object that holds all command info.

This assumes that the iterator remains invariant after growing the vector. That is not true. C++ vectors are not like C arrays. Iterators (save the last one entered) no longer point to valid memory after the vector grows by one member.

The least disturbing solution in the current scheme is first to read the band files, and then to store the info for each command.

Merge request reports