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);
graph();
rootapp->Run();
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");
mg->Add(gr1);
mg->Add(gr2);
TCanvas * c3 =new TCanvas("c3","A Multigraph");
mg->GetXaxis()->SetRangeUser(0.,1.); //the program property works without this line
mg->Draw("AL");
}
and this is the crash
*** Break *** segmentation violation
===========================================================
There was a crash (#6 0xb6c4accb in SigHandler(ESignals) () from /usr/local/lib/root/libCore.so.5.34).
This is the entire stack trace of all threads:
===========================================================
#0 0xb77bb424 in __kernel_vsyscall ()
#1 0xb68107c3 in waitpid () from /lib/i386-linux-gnu/libc.so.6
#2 0xb6796ff3 in ?? () from /lib/i386-linux-gnu/libc.so.6
#3 0xb6c4395b in TUnixSystem::Exec(char const*) () from /usr/local/lib/root/libCore.so.5.34
#4 0xb6c48090 in TUnixSystem::StackTrace() () from /usr/local/lib/root/libCore.so.5.34
#5 0xb6c4abb7 in TUnixSystem::DispatchSignals(ESignals) () from /usr/local/lib/root/libCore.so.5.34
#6 0xb6c4accb in SigHandler(ESignals) () from /usr/local/lib/root/libCore.so.5.34
#7 0xb6c41a02 in sighandler(int) () from /usr/local/lib/root/libCore.so.5.34
#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
http://root.cern.ch/bugs. 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
Thanks