You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The LB halo communication framework relies on undefined behavior to calculate the length of strides. The use of int to calculate a pointer offset leads to an integer overflow for LB grids of size 9x9x9 or larger. UBSAN report:
/work/jgrad/espresso/src/core/grid_based_algorithms/halo.cpp:112:19: runtime error: signed integer overflow: 10648 * 202232 cannot be represented in type 'int'
#0 in halo_dtset(char*, int, _Fieldtype*) /work/jgrad/espresso/src/core/grid_based_algorithms/halo.cpp:112:19
#1 in halo_communication(HaloCommunicator const*, char*) /work/jgrad/espresso/src/core/grid_based_algorithms/halo.cpp:307:7
#2 in lb_lbfluid_on_integration_start() /work/jgrad/espresso/src/core/grid_based_algorithms/lb_interface.cpp:128:5
#3 in on_integration_start() /work/jgrad/espresso/src/core/event.cpp:109:3
#4 in integrate(int, int) /work/jgrad/espresso/src/core/integrate.cpp:188:3
#5 in mpi_integrate_local(int, int) /work/jgrad/espresso/src/core/integrate.cpp:405:3
MWE: compile ESPResSo with UBSAN and run the integration test lb_poiseuille_cylinder.py with the following change:
diff --git a/testsuite/python/lb_poiseuille_cylinder.py b/testsuite/python/lb_poiseuille_cylinder.py
index f0dee7984..981c0c23e 100644
--- a/testsuite/python/lb_poiseuille_cylinder.py+++ b/testsuite/python/lb_poiseuille_cylinder.py@@ -90,4 +90,6 @@ class LBPoiseuilleCommon:
"""
+ # disable periodicity except in the flow direction+ self.system.periodicity = np.logical_not(self.params['axis'])
local_lb_params = LB_PARAMS.copy()
local_lb_params['ext_force_density'] = np.array(
This was never caught in CI because the part of the code in question is not covered by tests.
The text was updated successfully, but these errors were encountered:
Fixes#4077
Description of changes:
- improve testing of halo communication
- fix undefined behavior in halo communication
- fix mixed type expressions flagged as alerts by LGTM
The LB halo communication framework relies on undefined behavior to calculate the length of strides. The use of
int
to calculate a pointer offset leads to an integer overflow for LB grids of size 9x9x9 or larger. UBSAN report:MWE: compile ESPResSo with UBSAN and run the integration test
lb_poiseuille_cylinder.py
with the following change:This was never caught in CI because the part of the code in question is not covered by tests.
The text was updated successfully, but these errors were encountered: