Crash using copy of a pointer

Hi,
I think in the previous root version I was able to use the copy of a pointer
for working with a file based histogram.
Now I get systematically a crash:

_produit@yoga$ root result.root
   ------------------------------------------------------------
  | Welcome to ROOT 6.14/00                http://root.cern.ch |
  |                               (c) 1995-2018, The ROOT Team |
  | Built for linuxx8664gcc                                    |
  | From tag v6-14-00, 13 June 2018                            |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------

root [0] 
Attaching file result.root as _file0...
(TFile *) 0x55b4d0030ae0
root [1] .ls
TFile**		result.root	
 TFile*		result.root	
  KEY: TH1I	g2;1	g2
  KEY: TH2I	g20;1	g20
  KEY: TH2I	g21;1	g21
root [2] g2
(TH1I *) 0x55b4cffcd5a0
root [3] g2->Draw()
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [4] h=g2
(TH1I *) @0x7ffe437aefa8
root [5] h->Draw()

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f1d4a71a687 in __GI___waitpid (pid=4692, stat_loc=stat_loc
entry=0x7ffe437aca68, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
#1  0x00007f1d4a685067 in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:149
#2  0x00007f1d4b318a8b in TUnixSystem::StackTrace() () from /home/produit/root/lib/libCore.so
#3  0x00007f1d4b31b474 in TUnixSystem::DispatchSignals(ESignals) () from /home/produit/root/lib/libCore.so
#4  <signal handler called>
#5  0x00007f1d3d823028 in vtable for TH1I () from /home/produit/root/lib/libHist.so
#6  0x00007f1d4b96f0b5 in ?? ()
#7  0x000055b4cf4ec880 in ?? ()
#8  0x00007f1d45e096a0 in ?? () from /home/produit/root/lib/libCling.so
#9  0x000055b4cf214cc0 in ?? ()
#10 0x000055b4d0648cd8 in ?? ()
#11 0x00007f1d45e981a0 in ?? () from /home/produit/root/lib/libCling.so
#12 0x00007ffe437af960 in ?? ()
#13 0x00007ffe437af590 in ?? ()
#14 0x00007f1d45e0e687 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) [clone .part.303] () from /home/produit/root/lib/libCling.so
#15 0x00007f1d45e0eadf in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/produit/root/lib/libCling.so
#16 0x00007f1d45e0f2c7 in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) () from /home/produit/root/lib/libCling.so
#17 0x00007f1d45ebf99d in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /home/produit/root/lib/libCling.so
#18 0x00007f1d45d63b1e in HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) () from /home/produit/root/lib/libCling.so
#19 0x00007f1d45d794cd in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /home/produit/root/lib/libCling.so
#20 0x00007f1d4b1c6959 in TApplication::ProcessLine(char const*, bool, int*) () from /home/produit/root/lib/libCore.so
#21 0x00007f1d4b6a77a2 in TRint::ProcessLineNr(char const*, char const*, int*) () from /home/produit/root/lib/libRint.so
#22 0x00007f1d4b6a7b14 in TRint::HandleTermInput() () from /home/produit/root/lib/libRint.so
#23 0x00007f1d4b31a860 in TUnixSystem::CheckDescriptors() () from /home/produit/root/lib/libCore.so
#24 0x00007f1d4b31c1f8 in TUnixSystem::DispatchOneEvent(bool) () from /home/produit/root/lib/libCore.so
#25 0x00007f1d4b231cc1 in TSystem::Run() () from /home/produit/root/lib/libCore.so
#26 0x00007f1d4b1c498f in TApplication::Run(bool) () from /home/produit/root/lib/libCore.so
#27 0x00007f1d4b6a91f3 in TRint::Run(bool) () from /home/produit/root/lib/libRint.so
#28 0x000055b4cd526a6c in main ()
===========================================================


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.
===========================================================
#5  0x00007f1d3d823028 in vtable for TH1I () from /home/produit/root/lib/libHist.so
#6  0x00007f1d4b96f0b5 in ?? ()
#7  0x000055b4cf4ec880 in ?? ()
#8  0x00007f1d45e096a0 in ?? () from /home/produit/root/lib/libCling.so
#9  0x000055b4cf214cc0 in ?? ()
#10 0x000055b4d0648cd8 in ?? ()
#11 0x00007f1d45e981a0 in ?? () from /home/produit/root/lib/libCling.so
#12 0x00007ffe437af960 in ?? ()
#13 0x00007ffe437af590 in ?? ()
#14 0x00007f1d45e0e687 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) [clone .part.303] () from /home/produit/root/lib/libCling.so
#15 0x00007f1d45e0eadf in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/produit/root/lib/libCling.so
#16 0x00007f1d45e0f2c7 in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) () from /home/produit/root/lib/libCling.so
#17 0x00007f1d45ebf99d in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /home/produit/root/lib/libCling.so
#18 0x00007f1d45d63b1e in HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) () from /home/produit/root/lib/libCling.so
===========================================================

Use proper C++:

TH1 *g2; gDirectory->GetObject("g2", g2);
g2->Draw();
auto h = g2;
h->Draw();

Hi,
Ok it is not proper C++ but many example are given like that and use to work.

interesting:
root result.root
h=g2
h->Draw()
create a crash

root result.root
auto h=g2
h->Draw()
works

In both case h is a:
(TH1I *) @0x7ff

Why auto is makeing a difference. The object was inferred the same type

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