[MOAB-dev] compute_partition_sqij corruption

Vijay S. Mahadevan vijay.m at gmail.com
Mon Jan 28 08:09:28 CST 2019


Dear Michel,

Can you test the change submitted in PR #415 [1] so that we can verify
that it fixes your issue ? Do let us know and if you have more changes
to get your tests working locally. We would also appreciate your
comments and patches directly on the Bitbucket PR if possible.

Thanks,
Vijay

[1] https://bitbucket.org/fathomteam/moab/pull-requests/415

On Thu, Jan 17, 2019 at 9:24 AM Vijay S. Mahadevan <vijay.m at gmail.com> wrote:
>
> 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