Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-6484

Memory leak in `Future<T>::after()`

    XMLWordPrintableJSON

    Details

    • Target Version/s:
    • Sprint:
      Mesosphere Sprint 48

      Description

      The problem arises when one tries to associate an after() call to copied futures. The following test case is enough to reproduce the issue:

      TEST(FutureTest, After3)
      {
        auto policy = std::make_shared<int>(0);
      
        {
          auto generator = []() {
            return Future<Nothing>();
          };
      
          Future<Nothing> future = generator()
            .after(Milliseconds(1),
              [policy](const Future<Nothing>&) {
                 return Nothing();
              });
      
          AWAIT_READY(future);
        }
      
        EXPECT_EQ(1, policy.use_count());
      }
      

      In the test, one would expect that there is only one active reference to policy, therefore the expectation EXPECT_EQ(1, policy.use_count()). However, if after is triggered more than once, each extra call adds one undeleted reference to policy.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                arojas Alexander Rojas
                Reporter:
                arojas Alexander Rojas
                Shepherd:
                Joris Van Remoortere
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: