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

TApplication dies when Run(kTRUE)

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • High
    • Resolution: Unresolved
    • 5.34/36, 6.06/06
    • None
    • Core Libraries
    • None
    • Linux / x86_64

    Description

      This is a long-standing problem in ROOT 5 and 6.

      See the most recent thread: https://root.cern.ch/phpBB3/viewtopic.php?f=3&t=22107

      If one creates a stack-based TApplication object in "main" and executes "app.Run(kTRUE)", then ROOT (after "canvas_main_menu" -> "File" -> "Quit ROOT") will die with a "segmentation violation" (this happens in both, ROOT 5.34/36 and ROOT 6.06/06):
      ------------------------------------------------------------

      #include <TApplication.h>
      #include <TF1.h>
      int main(int argc, char **argv) {
        TApplication app("app", &argc, argv);
        TF1 *f = new TF1 ("f", "sin(x)/x", -1, 10); f->Draw();
        app.Run(kTRUE);
        return 0;
      }
      

      ------------------------------------------------------------

      In ROOT 5 (e.g. 5.34/36), you can "solve" it by using a heap-based TApplication object:
      ------------------------------------------------------------

      #include <TApplication.h>
      #include <TF1.h>
      int main(int argc, char **argv) {
        TApplication *app = new TApplication("app", &argc, argv);
        TF1 *f = new TF1 ("f", "sin(x)/x", -1, 10); f->Draw();
        app->Run(kTRUE);
        return 0;
      }
      

      ------------------------------------------------------------

      Of course, it is not clear if this problem is really "solved" in ROOT 5 or if it is just "hidden" (i.e. it does not appear clearly) ... especially that ... unfortunately, in ROOT 6 (I just tried 6.06/06) one still gets (after "canvas_main_menu" -> "File" -> "Quit ROOT"):
      ------------------------------------------------------------

      *** Error in `./app': double free or corruption (!prev): 0x0000000001cf12a0 ***
      Aborted (core dumped)
      

      ------------------------------------------------------------

      So, for the moment, with ROOT 6, you ALWAYS need to use "app->Run(kFALSE);" (so that your "TApplication" does NOT return into your "main" at all).

      Attachments

        Activity

          People

            couet Olivier Couet
            a75c91cec93196f04a74 Wile E. Coyote
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: