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

pyROOT issue with std::shared_ptr in 6.22/00

    XMLWordPrintable

    Details

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

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              etejedor Enric Tejedor Saavedra
              Reporter:
              chgreen Christopher Green
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: