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

The use of testcube-dense-fs results in a std::out_of_range error. #304

Open
GuoYongFa opened this issue May 12, 2024 · 1 comment
Open

Comments

@GuoYongFa
Copy link

When running with the configuration file "examples/force-exchange/testcube-dense-fs.xml", I encountered an index out-of-bounds issue.
Below, I've added comments hypothesizing the potential cause of this error, though I admit my usage is limited and I'm not entirely sure if my speculation is correct.
My operating system is Ubuntu 22.04, with gcc version 11.4.0.

if (currentCell.isBoundaryCell()) {
		cellProcessor.processCell(currentCell);
		// loop over all forward neighbours
		for (auto& neighbourOffset : this->_forwardNeighbourOffsets) {
			CellTemplate& neighbourCell = this->_cells->at(cellIndex + neighbourOffset);    // Exceeding the maximum index of an array 
			cellProcessor.processCellPair(currentCell, neighbourCell);
		}
		// loop over all backward neighbours. calculate only forces
		// to neighbour cells in the halo region, all others already have been calculated
		for (auto& neighbourOffset : this->_backwardNeighbourOffsets) {
			CellTemplate& neighbourCell = this->_cells->at(cellIndex - neighbourOffset);   // The value of cellindex might be less than neighbourOffset, leading to an overflow.
			if (neighbourCell.isHaloCell()) {
				cellProcessor.processCellPair(currentCell, neighbourCell);
			}
		}
	} // if ( isBoundaryCell() )
@HomesGH
Copy link
Contributor

HomesGH commented May 30, 2024

I think that the problem is here:
this->_cells->at(cellIndex - neighbourOffset)
This can lead to "negative" (-> overflowed) results. Unfortunately, I am not really into this part of the code and I am not sure if this traversal is still in use at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants