Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-20027

Apparent file handle leaks in Image FITS reading

    Details

    • Type: Story
    • Status: To Do
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: afw
    • Labels:
      None
    • Templates:
    • Story Points:
      4
    • Team:
      Data Release Production

      Description

      DM-20024 seems to have been caused by file handles leaking when an attempt is made to read an Image from an HDU that does not exist.  That ticket was addressed by changing higher-level logic to avoid depending on the resulting exception to determine the maximum HDU in a file, but the leak presumably still exists.

      The code being called that I've looked at looks clean; so it's either too subtle for my eyes to see, or there's a problem down in CFITSIO:

      • the Image constructor constructs and uses an ImageFitsReader, which holds an afw::fits::Fits instance that is explicitly deleted in its destructor;
      • that afw::fits::Fits instance is initialized with the AUTO_CLOSE flag, which means it calls CFITSIO to close the file in its own destructor.

      This is much more manual destructor logic than modern C++ code should be using; that's a historical artifact of the afw::fits::Fits class being a very shallow attempt to make it more convenient to use CFITSIO's (C) APIs, rather than a complete wrapper that rigorously manages resources.  Changing that now would be quite disruptive and difficult - CFITSIO's APIs do not map well to clean C++ ownership patterns - but it may yet be an overall win for the operations era, as there is a lot of scary code here.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jbosch Jim Bosch
                Watchers:
                Jim Bosch
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Summary Panel