Incompact3d icon indicating copy to clipboard operation
Incompact3d copied to clipboard

IBM - Invalid memory access in special cases (iibm=3)

Open mathrack opened this issue 1 year ago • 0 comments

The present issue is specific to IBM simulations with spline reconstruction (iibm=3). The variable ipol can be used without being defined. This issue can lead to undefined behavior and out of bounds memory access.

https://github.com/xcompact3d/Incompact3d/blob/46e874e236265c2f2671f254a9e3f4415d1e40d0/src/ibm.f90#L524

The situation is similar for the variable jpol :

https://github.com/xcompact3d/Incompact3d/blob/46e874e236265c2f2671f254a9e3f4415d1e40d0/src/ibm.f90#L691

The situation is similar for the variable kpol but for some unknown reason the code is commented :

https://github.com/xcompact3d/Incompact3d/blob/46e874e236265c2f2671f254a9e3f4415d1e40d0/src/ibm.f90#L842

Some deep review of the iibm=3 code capability is needed. As a temporary workaround, I suggest the following :

  • Print a warning for all simulations with iibm=3 to describe the option as experimental
  • When the code is reaching the special case leading to undefined behavior, abort the simulation with an error message

mathrack avatar Sep 11 '24 15:09 mathrack