Source: octave-dicom Severity: normal X-Debbugs-Cc: daniel.bung...@canonical.com
Dear Maintainer, I wanted to forward along a fix I have done for Ubuntu for octave-dicom. Ubuntu builds of octave-dicom were FTBFS on the built-in testsuite with use-after-free / segfault type issues. I have not reproduced this build failure on Sid, but memory corruption issues are treacherous and might show up later. If desired, more details can be found at https://bugs.launchpad.net/ubuntu/+source/octave-dicom/+bug/2069660 , but the summary is that I have moved the std::maps used by dicomdict to static storage to address this. I believe that the destructors are getting confused with the multiple copies of dicomdict, due to the functionality being built into several plugins and plugins being loaded by octave with RTLD_GLOBAL. The patch passes the built-in testsuite, along with my attempts to confuse the dict information loaded with specific plugin ordering. Please see attached. Also, the upstream bug tracker at https://octave.space/savannah/?Action=get&Format=HTMLCSS&Title=[octave%20forge]%20(dicom) seems to be down, so if you have information about how best to reach upstream, I'd appreciate it. -Dan P.S. - this is my second attempt at forwarding this, so if you see a duplicate assume mailserver weirdness and just close it.
Description: fix use-after-free due to symbol collisions across plugins Bug-Ubuntu: https://bugs.launchpad.net/bugs/2069660 Forwarded: no Last-Update: 2024-06-28 Move these symbols to static, which helps shield them from strange cleanup ordering of the maps that can result in use-after-free due to the map destructors performing an overwriting clear and that the symbols are referenced from multiple plugins. --- a/src/dicomdict.cpp +++ b/src/dicomdict.cpp @@ -51,9 +51,9 @@ const char * factory_dicom_dict_filename="octavedicom.dic"; static std::string dic_filename(factory_dicom_dict_filename); -std::map<gdcm::Tag, std::string> tagmap ; -std::map<std::string, gdcm::Tag> keymap ; -std::map<std::string, gdcm::DictEntry> dict ; +static std::map<gdcm::Tag, std::string> tagmap ; +static std::map<std::string, gdcm::Tag> keymap ; +static std::map<std::string, gdcm::DictEntry> dict ; void insert(const char *k, const gdcm::Tag t, const gdcm::DictEntry e) {