# Segfault passing a map array by value

**URL:** https://community.freefem.org/t/segfault-passing-a-map-array-by-value/4016
**Category:** General Discussion
**Created:** [July 25, 2025, 7:33am UTC](https://community.freefem.org/t/segfault-passing-a-map-array-by-value/4016 "2025-07-25T07:33:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jtermens](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@jtermens](https://community.freefem.org/u/jtermens)
#### Post date: [July 25, 2025, 7:33am UTC](https://community.freefem.org/t/segfault-passing-a-map-array-by-value/4016/1 "2025-07-25T07:33:02Z")

</div>

Hi everyone,

I’ve been exploring different ways to encapsulate mesh creation in FreeFem++ (version 4.15), experimenting with the available data types. My goal is to build a catalog of functions, each of which takes a structure containing mesh parameters and returns a different mesh. While the parameters may vary between meshes, the structure should remain consistent.

I’ve tested passing the mesh parameters as an array:

`func mesh meshFunction(real[int] meshParameters)`

and as a dictionary (dynamic map):

`func mesh meshFunction(real[string] meshParameters)`

Passing an array works as expected and the script exits without error. However, passing a real[string] map causes a segmentation fault. After some testing, I noticed that both function definitions pass their arguments by value. I then tried passing the real[string] map by reference:

`func mesh meshFunction(real[string]& meshParameters)`

and it worked. 🙂

I suspect there might be an issue with how `map<string, real>` is copied when passed by value, potentially causing a segmentation fault at the level of the virtual machine. I’m not sure whether this is a known issue, but I thought I’d share it in case it’s helpful to others encountering similar problems.

I’ve attached a minimal working example below.  
[mesh\_dict.edp](https://community.freefem.org/uploads/short-url/sCm9rkPeh8w09ydIm5hHuPVJer.edp) (1.9 KB)
