Open dschlaep opened 1 year ago
The problem in killAnnuals ST_mortality.c:1161 seems to be the sp variable receiving a new value inside the for loop parameters. It's causing the RGroup[rg]->est_spp[] array to read into an index that doesn't exist. Setting the value in the for loop itself seems to fix the issue:
for(i=RGroup[rg]->est_count; i>0; --i){ sp=RGroup[rg]->est_spp[i-1] Species_Annual_Kill(sp, 4); sp=RGroup[rg]->est_spp[(--i) - 1] }
I'll try to look into the additional issues!
killAnnuals() was trying to access outside of the RGroup[rg]->est_spp[] array. Most of the other memory errors were related to deallocate_Globals. Moving:
if(!isGriddedMode){
Mem_Free(Env);
Mem_Free(Succulent);
Mem_Free(Globals);
Mem_Free(Plot);
Mem_Free(_SomeKillage);
}
to the bottom of the function instead of at the top fixed them.
@N1ckP3rsl3y found memory issues when running STEPWAT2 on an ubuntu box. I find address errors on my macOS with a suitable compiler if I add a few additional flags when compiling. We find the same errors on all branches, including current master branch, Seed_Dispersal branches (as well as on the feature branch on which Nicholas is currently working on).
The clang compiler that comes with macOS is not suitable because it does not include an address sanitizers; the gcc that I have doesn't have address sanitizers either; clang15 or similar works well for me.
When the makefile is modified by
CC = gcc
andCXX = g++
(so that we can pass in a suitable compiler)CFLAGS = ...
:Then, we get for
CC=clang CXX=clang++ make clean bint_testing_nongridded
There are additional address issues popping up after addressing
killAnnuals()
: