sandbox/bugs/foreach_bnd.c

qcc -O2 -DMTRACE=3 -g -Wall -pipe -D_FORTIFY_SOURCE=2 -o foreach_bnd/foreach_bnd foreach_bnd.c -lm
make: * [foreach_bnd.tst] Error 1

This simple code shows a problem with the usage of foreach_boundary with curvature.h and tree meshes. Once this code runs, you will see “Segmentation fault” error. This problem doesn’t happen when the multigrid mesh is used.

#include "grid/quadtree.h"
#include "run.h"
#include "fractions.h"
#include "curvature.h"

int main(){
  init_grid(16);
  L0 = 1.0;
  origin(0.,0.,0.);
  run();
}

event init(i=0){
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/x86_64-linux-gnu/libthread_db.so.1”.
Program received signal SIGSEGV, Segmentation fault.
  foreach_boundary(left)
    printf("Hello.\n");
}