Seg fault in CharLS

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?

Hi @gcsharp ,

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

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.