# Buffer overflow error with parmmg

**URL:** <https://community.freefem.org/t/buffer-overflow-error-with-parmmg/3890>\
**Category:** General Discussion\
**Created:** [April 29, 2025, 6:25am UTC](https://community.freefem.org/t/buffer-overflow-error-with-parmmg/3890 "2025-04-29T06:25:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GiacomoSperoni97](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@GiacomoSperoni97](https://community.freefem.org/u/GiacomoSperoni97)\
**Post date:** [April 29, 2025, 6:25am UTC](https://community.freefem.org/t/buffer-overflow-error-with-parmmg/3890/1 "2025-04-29T06:25:39Z")

</div>

Dear community,

I am trying a simple test for the parallel version of mesh adaptation using `parmmg`, but I encountered an unexpected buffer overflow error.

Here is the code (taken from the example provided):

```auto
// Run with MPI: ff-mpirun -np 4 script.edp
// NBPROC 4

load "medit"
load "PETSc"
load "parmmg"
macro dimension()3// EOM
include "macro_ddm.idp"

mesh3 Th = cube(getARGV("-global", 30), getARGV("-global", 30), getARGV("-global", 30));
DmeshCreate(Th);
fespace Vh(Th, P1);
{
    mesh3 ThParMmg;
    int[int] n2o;
    int[int][int] communicators;
    ParMmgCreateCommunicators(Th, ThParMmg, n2o, communicators);
    fespace VhParMmg(ThParMmg, P1);
    VhParMmg met = sqrt((x-0.5)^2 + (y-0.5)^2 + (z-0.5)^2) - 0.3;
    real hmin = 2.0e-2;
    real hmax = 1.0e-0;
    met = max(hmin, min(hmax, abs(met)));
    mesh3 ThNew = parmmg3d(ThParMmg, metric = met[], hausd = 0.05, nodeCommunicators = communicators);
    DmeshReconstruct(ThNew);
    DmeshCopy(ThNew, Th);
    savevtk("ThNew_"+mpisize+".vtu", ThNew, bin = 0);
}

Vh u = sqrt((x-0.5)^2 + (y-0.5)^2 + (z-0.5)^2) - 0.3;
medit("Th", Th, u);

```

When I run this script on my machine with FreeFem++ version 4.15 (fresh installation), I get a buffer overflow error during the `parmmg` stage:

```auto
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   MODULE PARMMGLIB_DISTRIBUTED: IMB-LJLL : 1.5.0 (Nov. 01, 2024)
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
     git branch: HEAD
     git commit: cd8a6e340e466e857b0bb9952f115d8999337167
     git date: 2024-11-01 09:12:00 +0100

  -- PMMG: CHECK INPUT DATA
  -- CHECK INPUT DATA COMPLETED. 0.000s

  -- PHASE 1 : ANALYSIS
  ** SURFACE ANALYSIS
  ** SETTING TOPOLOGY

  -- PARALLEL MESH QUALITY 29791 162000
     BEST 0.657267 AVRG. 0.657267 WRST. 0.657267 (ELT 16880)
  -- PHASE 1 COMPLETED. 0.102s

  -- PHASE 2 : ISOTROPIC MESHING
***buffer overflow detected*** : terminated

```

Does anyone know why this might be happening, and if there is a workaround or fix?

Thank you very much in advance!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [April 29, 2025, 3:37pm UTC](https://community.freefem.org/t/buffer-overflow-error-with-parmmg/3890/2 "2025-04-29T15:37:28Z")

</div>

How many processes are you using? Everything runs fine on my end. Note that the problem is not too big, so you could just stick to Mmg.
