# \`munmap\_chunk(): invalid pointer\` when wrapping a C++ package

**URL:** https://discourse.julialang.org/t/munmap-chunk-invalid-pointer-when-wrapping-a-c-package/109205
**Category:** General Usage
**Tags:** binarybuilder, cxxwrap
**Created:** [January 24, 2024, 5:42pm UTC](https://discourse.julialang.org/t/munmap-chunk-invalid-pointer-when-wrapping-a-c-package/109205 "2024-01-24T17:42:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![biona001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/biona001/32/16497_2.png) [@biona001](https://discourse.julialang.org/u/biona001)
#### Post date: [January 24, 2024, 5:42pm UTC](https://discourse.julialang.org/t/munmap-chunk-invalid-pointer-when-wrapping-a-c-package/109205/1 "2024-01-24T17:42:24Z")

</div>

Hello community,

I’ve been trying to wrap a C++ package using CxxWrap.jl. My wrapper code and CMakeList.txt are available [here](https://github.com/biona001/ghostbasil/tree/master/julia), and they seem to work locally. Then, using [this build\_tarballs.jl](https://discourse.julialang.org/t/jll-package-is-pointing-to-an-older-artifacts-file/109183/4) I created a jll package [ghostbasil\_jll](https://github.com/biona001/ghostbasil_jll.jl) which is deployed to my github succesfully but seems to cause mysterious crashes in Julia.

**The problem:**  
I cannot get the `jll` package to work as intended even though my wrappers work locally. The current package crashes Julia on exit without running anything.

**MWE:** (this only works on Linux with julia 1.8.x and 1.9.x):

```julia
(@v1.8) pkg> add https://github.com/biona001/ghostbasil_jll.jl
julia> using CxxWrap
julia> using ghostbasil_jll
julia> @wrapmodule(ghostbasil_jll.get_libghostbasil_wrap_path)
julia> exit()

***Error in `julia': munmap_chunk(): invalid pointer: 0x00007fa6ff48e390***
======= Backtrace: =========
/lib64/libc.so.6(+0x7f474)[0x7fa7196ce474]
/home/groups/sabatti/.julia/artifacts/2702bda90fb3f2d2791de7a87abf4a78f55a597f/lib/libghostbasil_wrap.so(_ZN5jlcxx15FunctionWrapperISt6vectorIdSaIdEEJNS_8ArrayRefIdLi2EEES5_NS4_IdLi1EEES6_llmmbbmmmddmEED0Ev+0x34)[0x7fa6f2c4af44]
/home/groups/sabatti/.julia/artifacts/d25a86126e4d79572040fbf3f1fcda158a703a4a/lib/libcxxwrap_julia.so(_ZNSt15_Sp_counted_ptrIPN5jlcxx6ModuleELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv+0x105)[0x7fa6f784aba5]
/home/groups/sabatti/.julia/artifacts/d25a86126e4d79572040fbf3f1fcda158a703a4a/lib/libcxxwrap_julia.so(_ZNSt8_Rb_treeIP12_jl_module_tSt4pairIKS1_St10shared_ptrIN5jlcxx6ModuleEEESt10_Select1stIS8_ESt4lessIS1_ESaIS8_EE8_M_eraseEPSt13_Rb_tree_nodeIS8_E+0xb2)[0x7fa6f784af82]
/lib64/libc.so.6(+0x39ce9)[0x7fa719688ce9]
/lib64/libc.so.6(+0x39d37)[0x7fa719688d37]

... error truncated.

```

What could be going on here? I’m not sure if this is an issue with my C++ code, my [build\_tarballs.jl](https://discourse.julialang.org/t/jll-package-is-pointing-to-an-older-artifacts-file/109183/4), or something internal with CxxWrap.jl? But it seems to crash without calling any of my own code, so I’m not sure what to do. The error message is not meaningful to me.

---

<div class="post-metadata">

### Author: ![biona001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/biona001/32/16497_2.png) [@biona001](https://discourse.julialang.org/u/biona001)
#### Post date: [January 26, 2024, 5:00am UTC](https://discourse.julialang.org/t/munmap-chunk-invalid-pointer-when-wrapping-a-c-package/109205/2 "2024-01-26T05:00:48Z")

</div>

The issue was due to `libcxxwrrap_julia` releasing a breaking change, see [0.15 not yet registered (was Regression with 0.15) · Issue #402 · JuliaInterop/CxxWrap.jl · GitHub](https://github.com/JuliaInterop/CxxWrap.jl/issues/402)

It seems that for jll packages depending on `libcxxwrap_julia`, one should always specify a compat in the `build_tarballs.jl`, e.g.

```julia
Dependency("libcxxwrap_julia_jll"; compat = "0.11.2")

```
