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

Exceptions from importing lsst.afw.image cause SIGABRT

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: afw
    • Story Points:
      1
    • Team:
      Architecture

      Description

      If astropy.units fails to import and a raises an exception (eg if warnings are converted to errors) when being imported via Schema.cc during import of lsst.afw.image an abort signal is received:

      terminating with uncaught exception of type pybind11::error_already_set: SystemError: <built-in method __contains__ of dict object at 0x10049b900> returned a result with an error set
      

      Stepping through schema.cc the line triggering this is:

      * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
          frame #0: 0x0000000116e3d53d schema.so`void lsst::afw::table::(anonymous namespace)::declareSchemaType<unsigned char>(mod=0x00007ffeefbf33c0) at schema.cc:187 [opt]
         184 	    std::string suffix = FieldBase<T>::getTypeString();
         185 	    py::str pySuffix(suffix);
         186 	
      -> 187 	    py::object astropyUnit = py::module::import("astropy.units").attr("Unit");
         188 	
         189 	    // FieldBase
         190 	    PyFieldBase<T> clsFieldBase(mod, ("FieldBase" + suffix).c_str());
       
        * frame #0: 0x0000000116e3d53d schema.so`void lsst::afw::table::(anonymous namespace)::declareSchemaType<unsigned char>(mod=0x00007ffeefbf33c0) at schema.cc:187 [opt]
          frame #1: 0x0000000116e3d143 schema.so`lsst::afw::table::(anonymous namespace)::pybind11_init_schema(mod=0x00007ffeefbf33c0) at schema.cc:398 [opt]
          frame #2: 0x0000000116e3cf5d schema.so`::PyInit_schema() at schema.cc:390 [opt]
      
      

      Something in the pybind11 layer is failing to catch the python exception and forward it on.

      Depending on your system this can be reproduced with:

      import warnings
      warnings.simplefilter("error")
      import lsst.afw.image
      

      Given the reference to schema.cc and _contains_ I initially thought this was related to DM-15406 and there is some commentary there.

        Attachments

          Issue Links

            Activity

            Hide
            jbosch Jim Bosch added a comment -

            (All of this assumes that none of us actually understand why adding e.restore() prevents a C++ exception from propagating up to terminate - if you or Paul Price does and I'm just not seeing it, please speak up.)

            Show
            jbosch Jim Bosch added a comment - (All of this assumes that none of us actually understand why adding e.restore() prevents a C++ exception from propagating up to terminate - if you or Paul Price does and I'm just not seeing it, please speak up.)
            Hide
            tjenness Tim Jenness added a comment -

            Good news is that pybind11 master does not SIGABRT – you get the annoyingly incomplete rewritten exception text. I'll file a ticket anyhow to see if I can stop the exception rewriting. In the mean time I can merge this for the older pybind11 we have.

            Show
            tjenness Tim Jenness added a comment - Good news is that pybind11 master does not SIGABRT – you get the annoyingly incomplete rewritten exception text. I'll file a ticket anyhow to see if I can stop the exception rewriting. In the mean time I can merge this for the older pybind11 we have.
            Hide
            jbosch Jim Bosch added a comment - - edited

            Christopher Waters and I just ran into another error_already_set terminate in a new branch for DM-14980, so it'd definitely be nice to get this patch onto (LSST) master to make it easy to test if it fixes that problem as well.

            Show
            jbosch Jim Bosch added a comment - - edited Christopher Waters and I just ran into another error_already_set terminate in a new branch for DM-14980 , so it'd definitely be nice to get this patch onto (LSST) master to make it easy to test if it fixes that problem as well.
            Hide
            tjenness Tim Jenness added a comment -
            Show
            tjenness Tim Jenness added a comment - Filed as https://github.com/pybind/pybind11/issues/1498
            Hide
            tjenness Tim Jenness added a comment -

            Merged. Jenkins passed.

            Show
            tjenness Tim Jenness added a comment - Merged. Jenkins passed.

              People

              Assignee:
              tjenness Tim Jenness
              Reporter:
              tjenness Tim Jenness
              Reviewers:
              Jim Bosch
              Watchers:
              Jim Bosch, Paul Price, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.