Some thorns seem to incorrectly use CCTK_GFINDEX4D
A student in my group found the following problem in ID_converter_ILGRMHD
:
If you compile Einstein Toolkit in debug mode, the code crashes. This is due to the function CCTK_GFINDEX4D
that is used in some thorns (such as ID_converter_ILGRMHD
). The function is used to unroll a vector index into a linear one:
int CCTK_GFIndex4D (const cGH *GH, int i, int j, int k, int l)
{
#ifdef CCTK_DEBUG
if (i < 0 || i >= GH->cctk_lsh[0] ||
j < 0 || j >= GH->cctk_lsh[1] ||
k < 0 || k >= GH->cctk_lsh[2] ||
l < 0 || l >= GH->cctk_lsh[3])
{
CCTK_VError (__LINE__, __FILE__, "Cactus",
"Grid function index out of bounds. i=%d j=%d k=%d l=%d cctk_lsh=[%d,%d,%d,%d]",
i, j, k, l, GH->cctk_lsh[0], GH->cctk_lsh[1], GH->cctk_lsh[2], GH->cctk_lsh[3]);
}
#endif
return (i + GH->cctk_ash[0]*(j + GH->cctk_ash[1]*(k + GH->cctk_ash[2] * l)));
}
The code crashes when CCTK_DEBUG
because cctk_lsh[3] is 0, so the conditional in line 7 is not satisfied.
To reproduce, run magnetizedTOV.par
in IllinoisGRMHD with CCTK_DEBUG
enabled.
Comments (10)
-
-
-
assigned issue to
-
assigned issue to
-
- changed status to open
-
reporter Let me double check what version we are running, maybe it was fixed and I rushed into reporting it!
-
Oh, it still is in the current version (master, git hash 0cb4d23 "Baikal & BaikalVacuum codegen: Add pip install sympy==1.11 to the automated codegen instructions" of wvuthorns). We (@Zach Etienne and I) just missed it in the last round of removing
CCTK_GFINDEX4D
and also missed it when handling a slightly different issue inID_converter_ILGRMHD
that actually showed lines withCCTK_GFINDEX4D
in the ticket description. -
reporter Yes, we were running an older version and sorry for opening a duplicated ticket. The problem is now only in
wvuthorns_diagnostics
particle_tracerET/src/compute_particles_four_velocities.C: const double vU[3] = { vel[CCTK_GFINDEX4D(cctkGH,i,j,k,0)], particle_tracerET/src/compute_particles_four_velocities.C: vel[CCTK_GFINDEX4D(cctkGH,i,j,k,1)], particle_tracerET/src/compute_particles_four_velocities.C: vel[CCTK_GFINDEX4D(cctkGH,i,j,k,2)] }; particle_tracerET/src/convert_to_MHD_3velocity.C: double ETvx = vel[CCTK_GFINDEX4D(cctkGH,i,j,k,0)]; particle_tracerET/src/convert_to_MHD_3velocity.C: double ETvy = vel[CCTK_GFINDEX4D(cctkGH,i,j,k,1)]; particle_tracerET/src/convert_to_MHD_3velocity.C: double ETvz = vel[CCTK_GFINDEX4D(cctkGH,i,j,k,2)]; Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,0)] = -(y[index] + 0.5*dY)*A_b*pow(max(Pressure_at_Ax_stagger-P_cut,0.0),n_s); Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: if(!have_two_NSs_along_x_axis) Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,1)] = (xL + 0.5*dX)*A_b*pow(max(Pressure_at_Ay_stagger-P_cut,0.0),n_s); Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: if(r1<=r_NS1) Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,1)] = (x1 + 0.5*dX)*A_b*pow(max(Pressure_at_Ay_stagger-P_cut,0.0),n_s); Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: if(r2<=r_NS2) Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,1)] = (x2 + 0.5*dX)*A_b*pow(max(Pressure_at_Ay_stagger-P_cut,0.0),n_s); Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: if(r1>r_NS1 && r2>r_NS2) Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,1)] = 0.0; // No external B-field. Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,0)] = - (yL + 0.5 * dY) * (Ap1 + Ap2); Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,1)] = (x1 + 0.5 * dX) * Ap1 + (x2 + 0.5 * dX) * Ap2; Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,2)] = 0.0; Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,0)] = -y[index]*A_b*pow(max(PL-P_cut,0.0),n_s); Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,1)] = x[index]*A_b*pow(max(PL-P_cut,0.0),n_s); Seed_Magnetic_Fields_BNS/src/Seed_Magnetic_Fields.C: Avec[CCTK_GFINDEX4D(cctkGH,i,j,k,2)] = 0.0; smallbPoynET/src/compute_bi_b2_Poyn_fluxET.C: double ETvx = vel[CCTK_GFINDEX4D(cctkGH,i,j,k,0)]; smallbPoynET/src/compute_bi_b2_Poyn_fluxET.C: double ETvy = vel[CCTK_GFINDEX4D(cctkGH,i,j,k,1)]; smallbPoynET/src/compute_bi_b2_Poyn_fluxET.C: double ETvz = vel[CCTK_GFINDEX4D(cctkGH,i,j,k,2)]; smallbPoynET/src/compute_bi_b2_Poyn_fluxET.C: double Bx_center = Bvec[CCTK_GFINDEX4D(cctkGH,i,j,k,0)]; smallbPoynET/src/compute_bi_b2_Poyn_fluxET.C: double By_center = Bvec[CCTK_GFINDEX4D(cctkGH,i,j,k,1)]; smallbPoynET/src/compute_bi_b2_Poyn_fluxET.C: double Bz_center = Bvec[CCTK_GFINDEX4D(cctkGH,i,j,k,2)];
EDIT:
Oh, it still is in the current version (master, git hash 0cb4d23 "Baikal & BaikalVacuum codegen: Add pip install sympy==1.11 to the automated codegen instructions" of wvuthorns). We (@Zach Etienne and I) just missed it in the last round of removing
CCTK_GFINDEX4D
and also missed it when handling a slightly different issue inID_converter_ILGRMHD
that actually showed lines withCCTK_GFINDEX4D
in the ticket description.The message above was referring to the
master
of the repo -
yup. I had not updated my own repo. Sorry about the confusion.
particle_tracerET
is actually a newly submitted module in the Schwarzschild release. Anyhow, assigned to @Zach Etienne . -
I pushed a commit to
wvuthorns_diagnostics
to change theCCTK_GFINDEX4D
toCCTK_VECTGFINDEX3D
forSeed_Magnetic_Fields_BNS
,particle_tracerET
, andsmallbPoynET
. If there are any issues, let me know. -
I had missed one file in
particle_tracerET
, but I have pushed that as well now. I am closing the ticket sincegrep
ing forCCTK_GFINDEX4D
gets nothing inwvuthorns
andwvuthorns_diagnostics
. -
- changed status to resolved
- Log in to comment
Still? Grr. I thought that had been fixed in
but clearly this was missed and also missed in#2582.#2394Is this the only place or are you aware of others? What should be used is
CCTK_VECTGFINDEX3D
(curernlty at http://einsteintoolkit.org/referencemanual/ReferenceManual.html#x1-226000A2)