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

pyROOT issue with std::shared_ptr in 6.22/00



    • Bug
    • Status: Closed (View Workflow)
    • High
    • Resolution: Fixed
    • 6.22/00
    • master, 6.22/02
    • PyROOT
    • None


      In our standard pyROOT test, we encounter a fail-silent wrong answer with the following code:

      assert( not triggerResultsHandle.whyFailed() ); 

      where the Handle's whyFailed() function returns an std::shared_ptr<art::Exception>, where art::Exception is a typedef for cetlib::coded_exception<art::errors::ErrorCodes> with art::errors::ErrorCode being an enum. This worked in legacy PyROOT in 6.20/04.

      This being a somewhat complicated situation, Philippe worked with me to come up with a minimal (almost) reproducer. It doesn't quite replicate the problem, but it appears that we have a de-reference of an invalid pointer at some point (see output), so all bets are off. It appears that something might be trying to copy a temporary.

      import ROOT
      ROOT.gInterpreter.Declare("struct Empty {};")
      ROOT.gInterpreter.Declare("std::shared_ptr<Empty> GetSharedPtr(bool b) { return std::shared_ptr<Empty>(b ? std::make_shared<Empty>() : nullptr); }")
      ROOT.gInterpreter.Declare("std::shared_ptr<int> GetWorkingSharedPtr(bool b) { return std::shared_ptr<int>(b ? std::make_shared<int>() : nullptr); }")
      print( "expect True but is broken: ", ROOT.GetSharedPtr(0) == ROOT.nullptr )
      print( "expect True: ", ROOT.GetWorkingSharedPtr(0) == ROOT.nullptr )
      print(  ROOT.GetSharedPtr(0).__smartptr__())
      print(  ROOT.GetWorkingSharedPtr(0).__smartptr__())
      print( "expect True but is in the original reproducer broken: ", not ROOT.GetSharedPtr(0) )
      print( "expect True: ", not ROOT.GetWorkingSharedPtr(0) )
      print( "expect False: ", ROOT.GetSharedPtr(1) == ROOT.nullptr )
      print( "expect False: ", ROOT.GetWorkingSharedPtr(1) == ROOT.nullptr )
      print(  ROOT.GetSharedPtr(1).__smartptr__())
      print(  ROOT.GetWorkingSharedPtr(1).__smartptr__())
      print( "expect False: ", not ROOT.GetSharedPtr(1) )
      print( "expect False: ", not ROOT.GetWorkingSharedPtr(1) )

      Help appreciated: this stops us bringing our art-using experiments up to ROOT 6.22/00.


        1. r10870-reproducer.tar.bz2
          124 kB
          Christopher Green
        2. teardown.log
          6 kB
          Enric Tejedor Saavedra



            etejedor Enric Tejedor Saavedra
            chgreen Christopher Green (Inactive)
            0 Vote for this issue
            2 Start watching this issue