Floating point exception in TGraph::PaintPolyLineHatches

From: Nick West <n.west1_at_physics.ox.ac.uk>
Date: Thu, 20 Mar 2008 16:41:20 -0000


Dear Roottalk,

We (MINOS) have noticed that the following macro:-

  {

     (new TH2D("axes", "axes", 100, -5, 5, 100, -5, 5))->Draw();
     TGraph* g = new TGraph(2);
     g->SetPoint(0, -1, -5);
     g->SetPoint(1, -1, +5);
     g->SetLineWidth(1001);
     g->SetFillStyle(3004);
     g->Draw("l same");

  }

works fine if run in ROOT but fails:-

  Floating exception

if we run it in our off-line framework which is based on ROOT. Going in with the debugger reveals the source of the exception:-

  0x013aeade in TGraph::PaintPolyLineHatches (this=0xa67ecb0, n=2,x=0xa5a4b28, y=0xa5a4ba0) at graf/src/TGraph.cxx:3578   3578 a = TMath::ATan((yf[1]-yf[0])/(xf[1]-xf[0]));   Current language: auto; currently c++
(gdb) print xf[1]

  $1 = 0.42000000074505811
(gdb) print xf[0]

  $2 = 0.42000000074505811
(gdb) print yf[1]

  $3 = 0.61286863017098181
(gdb) print yf[0]

  $4 = 0.068096517282101213

so (xf[1]-xf[0]) is zero and (yf[1]-yf[0]) is not.

In our framework floating point exception is not disabled. Now we can quite understand why, for interactive work, floating exception suppression makes sense but would it be possible to catch cases like this as and when they get reported? In this case simply changing to ATan2 would suffice.

Thanks,

Nick West. Received on Thu Mar 20 2008 - 17:41:29 CET

This archive was generated by hypermail 2.2.0 : Thu Mar 20 2008 - 23:50:01 CET