team-charls/charls

Global visibility of variables causes seg faults in certain cases

gregsharp opened this issue · 2 comments

My program links to both ITK and dcmtk on Fedora 33. ITK is built from source whereas dcmtk is supplied by the OS package manager. This causes a crash at exit due to a double free of static variables within CharLS. Specifically it is these variables:

vector rgquant8Ll = CreateQLutLossless(8);
vector rgquant10Ll = CreateQLutLossless(10);
vector rgquant12Ll = CreateQLutLossless(12);
vector rgquant16Ll = CreateQLutLossless(16);

At program exit, ITK's static CharLS frees them, and then the dynamically linked CharLS frees them again causing a segmentation violation.

Could these be made internal to the shared library, e.g. by changing the visibility attribute?

In CharLS v2.1.0 and newer versions all symbols on Linux are hidden except the public API methods.

That is great news. Thank you!