TMultiGraph anomalies

Hi guys,
I’m having some problem with TMultiGraph: when I try to change the range of the Xaxis the program crashes.

here a code to reproduce the crash

#include <iostream>

#include <TMultiGraph.h>
#include <TApplication.h>
#include <TCanvas.h>

#include <TGraph.h>
#include <TAxis.h>
#include <TH1.h>

using namespace std;

void graph();

int main(int argc, char* argv[])
    TApplication* rootapp = new TApplication("example",&argc, argv);
    return 0;

void graph() {
   const Int_t n = 20;
   Double_t x[n], y1[n], y2[n];
   for (Int_t i=0; i<n; i++) {
     x[i] = i*0.1;
     y1[i] = 10*sin(x[i]+0.2);
     y2[i] = y1[i] + 2;
   TGraph* gr1 = new TGraph(n,x,y1);
   TGraph* gr2 = new TGraph(n,x,y2);

   TMultiGraph *mg = new TMultiGraph("mg","a multigraph");
   TCanvas * c3 =new TCanvas("c3","A Multigraph");
   mg->GetXaxis()->SetRangeUser(0.,1.);  //the program property works without this line

and this is the crash

*** Break *** segmentation violation

There was a crash (#6 0xb6c4accb in SigHandler(ESignals) () from /usr/local/lib/root/
This is the entire stack trace of all threads:
#0  0xb77bb424 in __kernel_vsyscall ()
#1  0xb68107c3 in waitpid () from /lib/i386-linux-gnu/
#2  0xb6796ff3 in ?? () from /lib/i386-linux-gnu/
#3  0xb6c4395b in TUnixSystem::Exec(char const*) () from /usr/local/lib/root/
#4  0xb6c48090 in TUnixSystem::StackTrace() () from /usr/local/lib/root/
#5  0xb6c4abb7 in TUnixSystem::DispatchSignals(ESignals) () from /usr/local/lib/root/
#6  0xb6c4accb in SigHandler(ESignals) () from /usr/local/lib/root/
#7  0xb6c41a02 in sighandler(int) () from /usr/local/lib/root/
#8  <signal handler called>
#9  0x080499fe in graph () at main.cpp:47
#10 0x08049824 in main (argc=1, argv=0xbfb0c764) at main.cpp:19

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
#9  0x080499fe in graph () at main.cpp:47
#10 0x08049824 in main (argc=1, argv=0xbfb0c764) at main.cpp:19

can someone help me?
It is a root bug or I’m doing something wrong?
My root version is 5.34_21


using cint for the same code I get:

root [16] mg->GetXaxis()->SetRangeUser(0.,1.); Error: illegal pointer to class object GetXaxis() 0x0 161 (tmpfile):1: *** Interpreter error recovered ***




   // gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
   mg->GetXaxis()->SetRangeUser(0., 1.);
   gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn

Hi Wile and thanks for your reply.
I tried your code and in this manner the program doesn’t crash but it doesn’t change the axis range…
some more hints?


Can it be that you left out the final “gPad” related calls?