Skip to content

bugfix: invlaid memory access in dm_update

This fixes a potential cause for an invalid memory access.

In fringe cases, update_DM may try to access an array element of dD outside its bounds.

This specifically happens when performing a TranSIESTA calculation where some orbitals are not updated (DM_update set to none for at least one electrode or when buffer atoms are used) and the distribution of sparse rows in SIESTA is such that some Nodes only hold orbitals for which the DM should not be updated. In this case, the number of elements in spDM on those Nodes is equal to zero, and dD(1,1) is technically an invalid memory access, because the first dimension of the array has size 0.

In practice, this should not have created any issues because this access is only made in one position when calling daxpy with 0 as the first argument. So no memory should be altered by this call. However, it causes the code to crash when array bounds are checked during execution.

Edited by Nils Wittemeier

Merge request reports