Backslash trees

Hi there,

consider this tiny program:

auto t = new TTree("t", "t");
char c[50] = "C:\\Windows";
t->Branch("c", c, "c/C");
t->Fill();
strlcpy(c, "D:\\other\\path", sizeof(c));
t->Fill();
strlcpy(c, "E:\\\\other\\\\path", sizeof(c));
t->Fill();
t->Draw("c");

Expectation: Draws histogram, using the path names as labels.

Result: (see plot below) ROOT cuts off the string at the first backslash, a double backslash is replaced with some whitespace. Is this a problem in ROOT or can this be caused by some global config/style settings?

It might be a stupid question, but why not using forward slashes instead of backslashes? @couet can probably give more details, but I think backslashes are used to escape special characters in the graphics subsystem (but I might be wrong)

Actually I was dealing with Windows usernames and Windows pathes coming out of a customer’s database. Usernames are DOMAIN\Pseudonym1 and Pathes contain backslashes. Forward slashes are just wrong in a Windows environment. Sure, I could replace all backslashes first (I have to convert the utf8 from the DB anyway to get correct umlauts and to remove non-Win1252 characters). But that would be more a work around than a solution.

Most probably ROOT is the wrong tool for this task. On the other hand I like exploring my data with ROOT and it is a fast way to get an impression on what that database really contains.

I just found the solution:
Replace the backslash with "\\backslash"!

Just found out that it is even worse, you can crash ROOT:

auto t = new TTree("t", "t");
char c[50] = "\\textbackslash";
t->Branch("c", c, "c/C");
t->Fill();
t->Draw("c");

This results in:

Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f47e9f1d07a in __GI___waitpid (pid=27053, stat_loc=stat_loc
entry=0x7ffe7d67a580, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1  0x00007f47e9e95fbb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2  0x00007f47eaad4c0d in TUnixSystem::Exec (shellcmd=<optimized out>, this=0x1ee8570) at /home/wbehrenh/src/root/root-head/core/unix/src/TUnixSystem.cxx:2118
#3  TUnixSystem::StackTrace (this=0x1ee8570) at /home/wbehrenh/src/root/root-head/core/unix/src/TUnixSystem.cxx:2412
#4  0x00007f47eaad725c in TUnixSystem::DispatchSignals (this=0x1ee8570, sig=kSigSegmentationViolation) at /home/wbehrenh/src/root/root-head/core/unix/src/TUnixSystem.cxx:3643
#5  <signal handler called>
#6  mathtext::math_text_renderer_t::math_tokenize (this=0x3d024c8, math_list_begin=<Fehler beim Lesen der Variable: Cannot access memory at address 0x0>, math_list_end=<Fehler beim Lesen der Variable: Cannot access memory at address 0x0>, style=style
entry=6) at /home/wbehrenh/src/root/root-head/graf2d/mathtext/src/mathrendertoken.cxx:191
#7  0x00007f47dc87cd50 in mathtext::math_text_renderer_t::math_bounding_box (this=<optimized out>, math_list_begin=<Fehler beim Lesen der Variable: Cannot access memory at address 0x0>, math_list_end=<Fehler beim Lesen der Variable: Cannot access memory at address 0x0>, style=style
entry=6) at /home/wbehrenh/src/root/root-head/graf2d/mathtext/src/mathrender.cxx:356
#8  0x00007f47dc87e0b4 in mathtext::math_text_renderer_t::math_bounding_box (this=this
entry=0x3d024c8, field=..., style=style
entry=6) at /home/wbehrenh/src/root/root-head/graf2d/mathtext/src/mathrender.cxx:506
#9  0x00007f47dc87e9bd in mathtext::math_text_renderer_t::bounding_box (this=this
entry=0x3d024c8, textbb=..., display_style=display_style
entry=false) at /home/wbehrenh/src/root/root-head/graf2d/mathtext/src/mathrender.cxx:684
#10 0x00007f47dc858aa3 in TMathText::GetSize (this=this
entry=0x7ffe7d67d4f0, x0=
0x7ffe7d67d420: 6.9530353580436597e-310, y0=
0x7ffe7d67d428: 6.9142927888906672e-310, x1=
0x7ffe7d67d430: 4.9406564584124654e-324, y1=
0x7ffe7d67d438: 3.1606573027064894e-316, size=size
entry=0.05000000074505806, angle=0, t=t
entry=0x7ffe7d67d449 "\\textbackslash") at /home/wbehrenh/src/root/root-head/graf2d/graf/src/TMathText.cxx:424
#11 0x00007f47dc85abf9 in TMathText::GetXsize (this=this
entry=0x7ffe7d67d4f0) at /home/wbehrenh/src/root/root-head/graf2d/graf/src/TMathText.cxx:516
#12 0x00007f47dc823102 in TLatex::GetXsize (this=this
entry=0x3d02320) at /home/wbehrenh/src/root/root-head/graf2d/graf/src/TLatex.cxx:2521
#13 0x00007f47dc831d17 in TGaxis::PaintAxis (this=this
entry=0x7ffe7d67dc50, xmin=xmin
entry=0, ymin=ymin
entry=0, xmax=xmax
entry=1, ymax=ymax
entry=0, wmin=
0x7ffe7d67dc30: 0, wmax=
0x7ffe7d67dc38: 1, ndiv=
0x7ffe7d67dc28: 1, chopt=chopt
entry=0x7f47d7e7b778 <THistPainter::PaintAxis(bool)::chopt> "SDH", gridlength=gridlength
entry=0, drawGridOnly=drawGridOnly
entry=false) at /home/wbehrenh/src/root/root-head/graf2d/graf/src/TGaxis.cxx:1233
#14 0x00007f47d7c5fab9 in THistPainter::PaintAxis (this=0x3cf5c70, drawGridOnly=<optimized out>) at /home/wbehrenh/src/root/root-head/hist/histpainter/src/THistPainter.cxx:4541
#15 0x00007f47d7c55725 in THistPainter::Paint (this=0x3cf5c70, option=0x3cb3fa1 "") at /home/wbehrenh/src/root/root-head/hist/histpainter/src/THistPainter.cxx:4272
#16 0x00007f47dcdb9f8b in TPad::PaintModified (this=0x3a2a800) at /home/wbehrenh/src/root/root-head/graf2d/gpad/src/TPad.cxx:3644
#17 0x00007f47dcd7b78c in TCanvas::Update (this=0x3a2a800) at /home/wbehrenh/src/root/root-head/graf2d/gpad/src/TCanvas.cxx:2285
#18 0x00007f47e56cb899 in TCling::UpdateAllCanvases () at /home/wbehrenh/src/root/root-head/core/metacling/src/TCling.cxx:6033
#19 0x00007f47e56d138d in TCling::ProcessLine (this=0x1f592a0, line=<optimized out>, error=0x0) at /home/wbehrenh/src/root/root-head/core/metacling/src/TCling.cxx:2102
#20 0x00007f47e56c809b in TCling::ProcessLineSynch (this=0x1f592a0, line=0x7f47e74ef9b8 "TRint::EndOfLineAction();", error=0x0) at /home/wbehrenh/src/root/root-head/core/metacling/src/TCling.cxx:3054
#21 0x00007f47eae2586b in TRint::HandleTermInput (this=0x1f20db0) at /home/wbehrenh/src/root/root-head/core/rint/src/TRint.cxx:637
#22 0x00007f47eaad66dc in TUnixSystem::CheckDescriptors (this=this
entry=0x1ee8570) at /home/wbehrenh/src/root/root-head/core/unix/src/TUnixSystem.cxx:1321
#23 0x00007f47eaad7b8a in TUnixSystem::DispatchOneEvent (this=0x1ee8570, pendingOnly=<optimized out>) at /home/wbehrenh/src/root/root-head/core/unix/src/TUnixSystem.cxx:1076
#24 0x00007f47ea9c8894 in TSystem::InnerLoop (this=0x1ee8570) at /home/wbehrenh/src/root/root-head/core/base/src/TSystem.cxx:411
#25 0x00007f47ea9c75af in TSystem::Run (this=0x1ee8570) at /home/wbehrenh/src/root/root-head/core/base/src/TSystem.cxx:361
#26 0x00007f47ea9d5b2f in TApplication::Run (this=this
entry=0x1f20db0, retrn=retrn
entry=false) at /home/wbehrenh/src/root/root-head/core/base/src/TApplication.cxx:1159
#27 0x00007f47eae26de7 in TRint::Run (this=this
entry=0x1f20db0, retrn=retrn
entry=false) at /home/wbehrenh/src/root/root-head/core/rint/src/TRint.cxx:455
#28 0x0000000000400cbc in main (argc=1, argv=0x7ffe7d6808a8) at /home/wbehrenh/src/root/root-head/main/src/rmain.cxx:30
===========================================================


The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum.
Only if you are really convinced it is a bug in ROOT then please submit a
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.
===========================================================
#6  mathtext::math_text_renderer_t::math_tokenize (this=0x3d024c8, math_list_begin=<Fehler beim Lesen der Variable: Cannot access memory at address 0x0>, math_list_end=<Fehler beim Lesen der Variable: Cannot access memory at address 0x0>, style=style
entry=6) at /home/wbehrenh/src/root/root-head/graf2d/mathtext/src/mathrendertoken.cxx:191
#7  0x00007f47dc87cd50 in mathtext::math_text_renderer_t::math_bounding_box (this=<optimized out>, math_list_begin=<Fehler beim Lesen der Variable: Cannot access memory at address 0x0>, math_list_end=<Fehler beim Lesen der Variable: Cannot access memory at address 0x0>, style=style
entry=6) at /home/wbehrenh/src/root/root-head/graf2d/mathtext/src/mathrender.cxx:356
#8  0x00007f47dc87e0b4 in mathtext::math_text_renderer_t::math_bounding_box (this=this
entry=0x3d024c8, field=..., style=style
entry=6) at /home/wbehrenh/src/root/root-head/graf2d/mathtext/src/mathrender.cxx:506
#9  0x00007f47dc87e9bd in mathtext::math_text_renderer_t::bounding_box (this=this
entry=0x3d024c8, textbb=..., display_style=display_style
entry=false) at /home/wbehrenh/src/root/root-head/graf2d/mathtext/src/mathrender.cxx:684
#10 0x00007f47dc858aa3 in TMathText::GetSize (this=this
entry=0x7ffe7d67d4f0, x0=
0x7ffe7d67d420: 6.9530353580436597e-310, y0=
0x7ffe7d67d428: 6.9142927888906672e-310, x1=
0x7ffe7d67d430: 4.9406564584124654e-324, y1=
0x7ffe7d67d438: 3.1606573027064894e-316, size=size
entry=0.05000000074505806, angle=0, t=t
entry=0x7ffe7d67d449 "  extbackslash") at /home/wbehrenh/src/root/root-head/graf2d/graf/src/TMathText.cxx:424
#11 0x00007f47dc85abf9 in TMathText::GetXsize (this=this
entry=0x7ffe7d67d4f0) at /home/wbehrenh/src/root/root-head/graf2d/graf/src/TMathText.cxx:516
#12 0x00007f47dc823102 in TLatex::GetXsize (this=this
entry=0x3d02320) at /home/wbehrenh/src/root/root-head/graf2d/graf/src/TLatex.cxx:2521
#13 0x00007f47dc831d17 in TGaxis::PaintAxis (this=this
entry=0x7ffe7d67dc50, xmin=xmin
entry=0, ymin=ymin
entry=0, xmax=xmax
entry=1, ymax=ymax
entry=0, wmin=
0x7ffe7d67dc30: 0, wmax=
0x7ffe7d67dc38: 1, ndiv=
0x7ffe7d67dc28: 1, chopt=chopt
entry=0x7f47d7e7b778 <THistPainter::PaintAxis(bool)::chopt> "SDH", gridlength=gridlength
entry=0, drawGridOnly=drawGridOnly
entry=false) at /home/wbehrenh/src/root/root-head/graf2d/graf/src/TGaxis.cxx:1233
#14 0x00007f47d7c5fab9 in THistPainter::PaintAxis (this=0x3cf5c70, drawGridOnly=<optimized out>) at /home/wbehrenh/src/root/root-head/hist/histpainter/src/THistPainter.cxx:4541
#15 0x00007f47d7c55725 in THistPainter::Paint (this=0x3cf5c70, option=0x3cb3fa1 "") at /home/wbehrenh/src/root/root-head/hist/histpainter/src/THistPainter.cxx:4272
#16 0x00007f47dcdb9f8b in TPad::PaintModified (this=0x3a2a800) at /home/wbehrenh/src/root/root-head/graf2d/gpad/src/TPad.cxx:3644
#17 0x00007f47dcd7b78c in TCanvas::Update (this=0x3a2a800) at /home/wbehrenh/src/root/root-head/graf2d/gpad/src/TCanvas.cxx:2285
#18 0x00007f47e56cb899 in TCling::UpdateAllCanvases () at /home/wbehrenh/src/root/root-head/core/metacling/src/TCling.cxx:6033
===========================================================
auto t = new TTree("t", "t");
char c[50] = "#backslash";
t->Branch("c", c, "c/C");
t->Fill();
t->Draw("c");

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.