hi,
I am seeing a corrupt memory read for: moab::ScdInterface::compute_partition_sqij
The issue is these lines:
double ijratio = ((double)(gijk[3]-gijk[0]))/((double)(gijk[4]-gijk[1]));
unsigned int ind = std::lower_bound(ppfactors.begin(), ppfactors.end(), ijratio) - ppfactors.begin();
if (ind && fabs(ppfactors[ind-1]-ijratio) < fabs(ppfactors[ind]-ijratio)) ind--;
If std::lower_bound returns ppfactors.end() for finding no match, then ind will be out of bounds.
Then ppfactors[ind] reads bad memory.
I attached a test to demonstrate this (test.cpp).
Even though the bad memory read always happens the code will coincidentally work out.
It may not fail until after several thousand runs.
I attached a batch script I use to detect this (run.sh).
I can’t see how ijratio is guaranteed to be below or equal one of the factors so perhaps we are not setting this up correctly.
Clamping ind resolves the issue for me but I’m not sure what the complete solution is here.
Thanks,
Michel