Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-10659

Crash on cleanup when python is embedded in the C++ binary

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 6.20/02
    • Fix Version/s: None
    • Component/s: Core Libraries, PyROOT
    • Labels:
      None
    • Environment:

      GCC 9.3, python3.8

      Description

      In the Belle2 software the main binary is handles some arguments and runs some setup, then initializes the python interpreter (Py_Initialize()), runs the given python script and exits.

      Now most scripts we run will import basf2 which loads a compiled python extension that is linked against the root libraries.

      This worked well with GCC 8, python 3.6 and 6.16. But now trying to upgrade to 6.20 we get a segfault in the cleanup procedure. According to valgrind, the gInterpreter is deleted before the cleanup in Cppyy.cc can finish.

      For reasons I don't understand, loading of our compiled python extension with our binary (which is also linked against ROOT) seems to change the destruction order. I added some printouts to constructors and destructor calls:

      • running a python script which doesn't do anything works fine

      basf2 framework/tests/test.py 
      TROOTAllocator()
      TROOT()
      ApplicationStarter()
      TROOT::InitInterpreter()
      [INFO] Steering file: framework/tests/test.py
      ~ApplicationStarter()
      ~TROOT
      ~TROOTAllocator()
      

      * running a python script which only imports the basf2 module

      TROOTAllocator()
      TROOT()
      ApplicationStarter()
      TROOT::InitInterpreter()
      [INFO] Steering file: framework/tests/test.py
      ~TROOT
      ~ApplicationStarter()
      Segmentation fault (core dumped)
      

      * running "import basf2" in just python also works fine.

        Attachments

        1. clingunload_v2.tar.gz
          130 kB
        2. gdb-showmember.log
          4 kB
        3. ld_debug_files.txt
          46 kB
        4. ldd.txt
          94 kB
        5. ldfiles.py
          2 kB
        6. root-8098-disable-dlcache.patch
          0.9 kB
        7. valgrind.log
          6 kB
        8. valgrind-debug.log
          12 kB

          Issue Links

            Activity

              People

              Assignee:
              vvasilev Vasil Georgiev Vasilev
              Reporter:
              9784214ad6c464d2626b Martin Ritter
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: