Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the out-of-bound bug #5

Merged
merged 2 commits into from Mar 28, 2016

Conversation

Projects
None yet
2 participants
@PytLab
Copy link
Contributor

PytLab commented Mar 28, 2016

Hi, Leetmaa,

I have found that there may be a out-of-bound risk in Configuration::initMatchLists() function.

You used the size of first of minimal match list in match lists to allocate the memories for moved_atom_ids_ and recent_moved_vectors_. But if the periodic of lattice map is not {true, true, ture}, the size of first minimal match list may smaller than that of minimal match list in the middle of lattice. Take a 3x3x3 lattice for example, the neighbor number of site0 is 8, but the number of neighbors of site 13 is 27, but the initial size of those two poor vectors are both 8 at first.
So there may be a risk of out-of -bound, using the maximum size of all minimal match list is better way i think.

I also add a new test function in unit test to make sure the sizes of those two vectors are safe. If using the first size, the test will be failed.

Thanks.
ShaoZhengjiang

PytLab added some commits Mar 28, 2016

Fix vector out-of-bound bug
It is not good to use the size of the first minimal match list of
configuration as the initial size of moved_atom_ids_ and
recent_moved_vectors.

So use the maximum size of minimal match list as the initial size of
moved_atom_ids_ and recent_moved_vectors instead to avoid possible
out-of-bound problem when the periodic is not {true, true, true}.
Add new test function
Add test function to check vector size of
moved_atom_ids_ and recent_moved_vectors,
they should be the largest size in all neighbors
for all elements in configuration

@leetmaa leetmaa merged commit cd782e9 into leetmaa:master Mar 28, 2016

@leetmaa

This comment has been minimized.

Copy link
Owner

leetmaa commented Mar 28, 2016

Thanks for the contribution. Your point is valid and the code looks nice. Changes accepted.

@PytLab PytLab deleted the PytLab:pullrequests branch Mar 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.