I am using root 5.17.04 on Windows XP with Visual Studio 8. I am running in Release mode.
I wrote a simple standalone program which works fine if the user does not interact with the canvas’s. But after several double clicks on the histogram canvas I always get a crash with:
libGpad.dll!TObjLink::GetObject() Line 129 + 0x11 bytes C++
libGpad.dll!TPad::Pick(int px=607, int py=162, TObjLink * & pickobj=0x01436f08) Line 3954 + 0x8 bytes C++
libGpad.dll!TCanvas::Pick(int px=607, int py=162, TObjLink * & pickobj=0x01436f08) Line 193 + 0x22 bytes C++
libGpad.dll!TCanvas::Pick(int px=607, int py=162, TObject * prevSelObj=0x03b17880) Line 1343 + 0x1e bytes C++
libGpad.dll!TCanvas::HandleInput(EEventType event=kMouseMotion, int px=607, int py=162) Line 1041 + 0x1e bytes C++
libGui.dll!TRootCanvas::HandleContainerMotion(Event_t * event=0x0012fdac) Line 1623 + 0x28 bytes C++
libGui.dll!TRootContainer::HandleMotion(Event_t * ev=0x0012fdac) Line 237 + 0x20 bytes C++
libGui.dll!TGFrame::HandleEvent(Event_t * event=0x0012fdac) Line 487 + 0x16 bytes C++
libGui.dll!TGClient::HandleEvent(Event_t * event=0x0012fdac) Line 753 + 0x16 bytes C++
libGui.dll!TGClient::ProcessOneEvent() Line 587 C++
libGui.dll!TGClient::HandleInput() Line 633 + 0x8 bytes C++
libGui.dll!TGInputHandler::Notify() Line 81 C++
libCore.dll!TWinNTSystem::DispatchOneEvent(bool pendingOnly=false) Line 1388 + 0x1b bytes C++
libCore.dll!TSystem::InnerLoop() Line 356 + 0x14 bytes C++
libCore.dll!TSystem::Run() Line 324 + 0x12 bytes C++
libCore.dll!TApplication::Run(bool retrn=false) Line 902 + 0x1c bytes C++
Plotter.exe!main(int argc=1, char * * argv=0x02043810) Line 60 C++
Plotter.exe!__tmainCRTStartup() Line 597 + 0x17 bytes C
kernel32.dll!7c816fd7()
My main loop is shown below:
#include "Plotter.h"
// other includes (have to come after root includes)
#include <iostream>
using namespace AWPlotter;
using namespace std;
namespace
{
PlotterPtr plotter(new Plotter());
vector<double> X;
vector<double> Y;
TRandom *r3 = new TRandom3();
}
//called from a thread
void* thePlotter(void *args)
{
double cnt = 0;
while (plotter->start())
{
double val = r3->Gaus();
cnt = cnt + 0.01;
X.push_back(cnt);
Y.push_back(val);
plotter->plotHistogram(val);
plotter->plotScatter(X, Y);
gSystem->Sleep(300); //300 ms
//gSystem->ProcessEvents();
}
std::cout << " We exit thread thePlotter\n";
return 0;
}
int main(int argc, char **argv)
{
TApplication theApp("App", &argc, argv);
plotter->init(20);
plotter->pad(1)->Connect("Closed()", "TApplication", &theApp, "Terminate()");
plotter->pad(2)->Connect("Closed()", "TApplication", &theApp, "Terminate()");
TThread *th1 = new TThread("th1", thePlotter);
th1->Run();
try
{
theApp.Run();
}
catch (...)
{
int iDum = 0;
}
plotter->setStart(false);
gSystem->Sleep(700);
th1->SetCancelAsynchronous();
th1->Kill();
std::cout << " We exited\n";
return 0;
}
I tried adding gSystem->ProcessEvents() with no luck. I tried replacing theApp.Run() with theApp.Run(kTRUE) with no luck. Each loop I create a TGraph and protect it with a TThread::Lock(). Do I need to explicitely try to process a mouse click event?
I am attaching the 3 files in my project as well as the project.
Thanks,
Sanjeev
Plotter.zip (4.47 KB)
Plotter.cpp (2.58 KB)
Plotter.h (1.46 KB)
main.cpp (1.37 KB)
more complicated. You are trying to make your piece of the code thread-safe. Yes, one has to do that. However, it can not help as soon as the core ROOT /Cint /ROOT Signal / ROOT Slot are not thread-safe. It is out of your control
. You can not
change the ROOT code to make it thread safe.[quote=“supandey”]
approach.
