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

FlagsBase copy-ctor leads to dangling pointer.

Attach filesAttach ScreenshotVotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.2.0
    • None
    • Mesosphere Sprint 44, Mesosphere Sprint 45
    • 8

    Description

      Per 3328, ubsan detects the following problem:

      [ RUN ] FaultToleranceTest.ReregisterCompletedFrameworks
      /mesos/3rdparty/libprocess/3rdparty/stout/include/stout/flags/flags.hpp:303:25: runtime error: load of value 33, which is not a valid value for type 'bool'

      I believe what is going on here is the following:

      • The test calls StartMaster(), which does MesosTest::CreateMasterFlags()
      • MesosTest::CreateMasterFlags() allocates a new master::Flags on the stack, which is subsequently copy-constructed back to StartMaster()
      • The FlagsBase constructor is:

        FlagsBase() { add(&help, "help", "...", false); }

        where "help" is a member variable – i.e., it is allocated on the stack in this case.

      • FlagsBase()::add captures &help, e.g.:
        flag.stringify = [t1](const FlagsBase&) -> Option<std::string> {
            return stringify(*t1);
          };}}
        
      • The implicit copy constructor for FlagsBase is just going to copy the lambda above, i.e., the result of the copy constructor will have a lambda that points into MesosTest::CreateMasterFlags()'s stack frame, which is bad news.

      Not sure the right fix – comments welcome. You could define a copy-ctor for FlagsBase that does something gross (basically remove the old help flag and define a new one that points into the target of the copy), but that seems, well, gross.

      Probably not a pressing-problem to fix – AFAICS worst symptom is that we end up reading one byte from some random stack location when serving state.json, for example.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            bbannier Benjamin Bannier
            neilc Neil Conway
            Michael Park Michael Park
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Agile

                Completed Sprints:
                Mesosphere Sprint 44 ended 14/Oct/16
                Mesosphere Sprint 45 ended 28/Oct/16
                View on Board

                Slack

                  Issue deployment