[MOAB-dev] compute_partition_sqij corruption

Vijay S. Mahadevan vijay.m at gmail.com
Thu Jan 17 08:24:44 CST 2019


Michel,

Thanks for letting us know about the issue. We will try to reproduce
the error and get back to you with a solution.

Vijay

On Tue, Jan 15, 2019 at 2:58 PM Michel de Messieres via moab-dev
<moab-dev at mcs.anl.gov> wrote:
>
> 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
>
>
>


More information about the moab-dev mailing list