# Segmentation fault with signed distance

**URL:** <https://community.freefem.org/t/segmentation-fault-with-signed-distance/638>\
**Category:** General Discussion\
**Created:** [November 5, 2020, 11:10am UTC](https://community.freefem.org/t/segmentation-fault-with-signed-distance/638 "2020-11-05T11:10:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lily](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lily](https://community.freefem.org/u/Lily)\
**Post date:** [November 5, 2020, 11:10am UTC](https://community.freefem.org/t/segmentation-fault-with-signed-distance/638/1 "2020-11-05T11:10:45Z")

</div>

Hello,

I have just installed FreeFem++ 4.7-1.  
There is a segmentation fault when trying to use the external library “distance”.  
I have already identify that the segmentation fault comes from the distance command and not from other things.  
Here’s an extract of my code :

load “msh3”  
load “distance”

real xA, yA, zA;   
xA = 0.25; yA = 0.7; zA = 0.1;  
real hmin1, hmax1;  
real R = 0.05;

mesh3 Th, Th10, Th20, Th1, Th2;  
Th10 = readmesh3(“mesh10.mesh”);

fespace Vh1(Th10,P1);  
Vh1 o1, o1dist;

o1 = (x-xA)^2+(y-yA)^2+(z-zA)^2-R^2;   
distance(Th10,o1,o1dist[],distmax=100);  
o1[] = o1dist[];  
savesol(“levelset1.sol”,Th10,o1);

Is there something wrong with the execution of the command?

Thanks or your help!

---

<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:** [November 5, 2020, 5:14pm UTC](https://community.freefem.org/t/segmentation-fault-with-signed-distance/638/2 "2020-11-05T17:14:54Z")

</div>

Impossible to help without the mesh.

---

<div class="post-metadata">

**Author:** ![Lily](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lily](https://community.freefem.org/u/Lily)\
**Post date:** [November 5, 2020, 8:01pm UTC](https://community.freefem.org/t/segmentation-fault-with-signed-distance/638/3 "2020-11-05T20:01:33Z")

</div>

Here are the meshes and the code : [https://we.tl/t-GO2gGLsutv](https://we.tl/t-GO2gGLsutv)

---

<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:** [November 5, 2020, 8:25pm UTC](https://community.freefem.org/t/segmentation-fault-with-signed-distance/638/4 "2020-11-05T20:25:43Z")

</div>

I don’t have any segfault. Are you sure you are using the `distance` plugin from your new installation, and not the one from your previous installation? Your main.edp is wrong, it should read `o2[] = o2dist[];`.  
Also, Mmg is now interfaced in FreeFEM, you don’t need those `exec` command, you can just load `mmg` instead, see [this](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/3d/Laplace-Adapt-aniso-3d.edp) example.

---

<div class="post-metadata">

**Author:** ![Lily](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lily](https://community.freefem.org/u/Lily)\
**Post date:** [November 6, 2020, 8:43am UTC](https://community.freefem.org/t/segmentation-fault-with-signed-distance/638/5 "2020-11-06T08:43:24Z")

</div>

In fact, I don’t know which plugin is used. How can I get the information?

Thank you for the correction of the code and the precision about Mmg.

---

<div class="post-metadata">

**Author:** ![Lily](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lily](https://community.freefem.org/u/Lily)\
**Post date:** [November 10, 2020, 9:44am UTC](https://community.freefem.org/t/segmentation-fault-with-signed-distance/638/6 "2020-11-10T09:44:23Z")

</div>

I uninstalled all my FreeFem versions and installed only the latest one. Everything is fine now.  
Thanks!
