# Seg fault in CharLS

**URL:** https://discourse.itk.org/t/seg-fault-in-charls/3940
**Category:** Engineering
**Created:** [March 8, 2021, 7:17pm UTC](https://discourse.itk.org/t/seg-fault-in-charls/3940 "2021-03-08T19:17:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gcsharp](https://discourse.itk.org/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@gcsharp](https://discourse.itk.org/u/gcsharp)
#### Post date: [March 8, 2021, 7:17pm UTC](https://discourse.itk.org/t/seg-fault-in-charls/3940/1 "2021-03-08T19:17:59Z")

</div>

Hi, I have a segmentation fault on program exit when linking to both ITK and dcmtk on Fedora 33. ITK is built from source whereas dcmtk is supplied by the OS package manager. The crash is a double free of static variables within CharLS. Specifically it is these variables:

```
vector<signed char> rgquant8Ll = CreateQLutLossless(8);
vector<signed char> rgquant10Ll = CreateQLutLossless(10);
vector<signed char> rgquant12Ll = CreateQLutLossless(12);
vector<signed char> rgquant16Ll = CreateQLutLossless(16);

```

At program exit, it frees them. Then the dynamically linked CharLS also tries to free them causing a segmentation violation.

Any thoughts how to avoid this issue? Could gdcm’s copy of CharLS be put into a namespace?

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [March 8, 2021, 7:20pm UTC](https://discourse.itk.org/t/seg-fault-in-charls/3940/2 "2021-03-08T19:20:01Z")

</div>

Hi @gcsharp ,

> [@gcsharp](#):
>
> Could gdcm’s copy of CharLS be put into a namespace?

Is it also possible to use the OS package manager version of GDCM?

---

<div class="post-metadata">

### Author: ![gcsharp](https://discourse.itk.org/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@gcsharp](https://discourse.itk.org/u/gcsharp)
#### Post date: [March 8, 2021, 8:47pm UTC](https://discourse.itk.org/t/seg-fault-in-charls/3940/3 "2021-03-08T20:47:00Z")

</div>

Indeed that does work. Thank you Matt.

Digging further, it seems this issue is best assigned to CharLS. Those variables shouldn’t need global visibility. I will contact them.
