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

[patch] "for e in getSTLLikeCollection()" crashes pyroot

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Medium
    • Resolution: Fixed
    • 6.06/00
    • 6.08/00, 6.06/06
    • PyROOT
    • None
    • -

    Description

      In PyROOT, trying to iterate over a collection returned from a function can result in destruction of the collection before its iterators, e.g.

      for elem in getset():
          print(elem)

      will crash, whereas

      s = getset()
      for elem in s:
          print(elem)

      , where s has a larger scope, will work as expected. (see attached test)

      I was able to fix this by adding a _collection attribute to the iterator in StlSequenceIter(), which ensures the reference count for the collection cannot reach 0 before the iteration is finished.

      std::vector is handled as a special case with its own iterator type by PyROOT and is not affected by this problem.

      Attachments

        Activity

          People

            mato Pere Mato Vila
            1a6d63d41e0230d528a8 Christian Pulvermacher
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Actual End: