Skip to content

Fix crash in testGravitySpeed unit test

Peter W. Draper requested to merge fix-gravityspeed-test into master

Currently segfaults somewhat randomly, checking the core dumps from that and running through the GCC sanitizer shows that we have alignment issues with the tensor allocations and missing elements of the gravity cache, like eps.

This fixes those, but we now have an issue with a random /0 at:

(gdb) where
#0  0x000000000055d238 in runner_dopair_grav_pp_full (ci_cache=0x7ffcd4a01d40, cj_cache=0x7ffcd4a02000, 
    gcount_i=8, gcount_j=8, gcount_padded_j=16, periodic=0, dim=0x7ffcd4a0115c, e=0x7ffcd4a022d0, 
    gparts_i=0x116fa10, gparts_j=0x116fed0) at runner_doiact_grav.c:617
#1  0x0000000000569cf4 in runner_dopair_grav_pp (r=0x7ffcd4a01d00, ci=0x7ffcd4a01880, cj=0x7ffcd4a01400, 
    symmetric=1, allow_mpole=0) at runner_doiact_grav.c:1229
#2  0x000000000041dceb in main (argc=1, argv=0x7ffcd4a038d8) at testGravitySpeed.c:319
(gdb) list
612           const float r2 = dx * dx + dy * dy + dz * dz;
613
614           /* Pick the maximal softening length of i and j */
615           const float h = max(h_i, h_j);
616           const float h2 = h * h;
617           const float h_inv = 1.f / h;
618           const float h_inv_3 = h_inv * h_inv * h_inv;
619
620     #ifdef SWIFT_DEBUG_CHECKS
621           if (r2 == 0.f && h2 == 0.)
(gdb) 

as h is zero.

Edited by Matthieu Schaller

Merge request reports