Re: still segfault with TObject::Read()

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon May 10 1999 - 12:03:31 MEST


Hi Ulrich,
As I already reported to you, I cannot reproduce your problem with
the PRO version of Root 2.21/08.
You should be able to do either:


void test(const char *filename)
{
  TFile* file = new TFile(filename, "read");
  TPaveText *pt = new TPaveText();
  pt->Read("annotation");       
  pt->Draw();
}

or

void test(const char *filename)
{
  TFile* file = new TFile(filename, "read");
  TPaveText *pt = (TPaveText*) file->Get("annotation");   
  pt->Draw();
}

The second version imports the object in memory (creating a TPaveText
object)

Rene Brun

Ulrich Jost wrote:
> 
> Hi,
> 
> having switched to the new(er)
> Version   2.21/01   14 January 1999
> on linux, I still get a segfault, both in macro and program, when I try to
> Read() from a file, see the code below. Attached is the data file.
> If I understood correctly, Read() makes a copy of the object in the
> file into the new program object, whereas TFile::Get() does not make a
> copy, so I have/want to use Read(). The file was written to with Write().
> 
> Thanks, Ulrich
> 
> Macro:
> void test(const char *filename)
> {
>   TFile* file = new TFile(filename, "read");
>   file.ls();
>   file.Map();
>   TPaveText *pt = new TPaveText();
>   //  pt->Read("annotation");                  // <- segfault !!!!
>   pt = (TPaveText*) file->Get("annotation");   // <- works fine
>   pt->Draw();
> 
>   return;
> }
> 
> Trace back from a program:
> 
> Program received signal SIGABRT, Aborted.
> 0x40aee781 in __kill ()
> (gdb) where
> #0  0x40aee781 in __kill ()
> #1  0x40aee5af in raise (sig=6) at ../sysdeps/posix/raise.c:27
> #2  0x40aef7bf in abort () at ../sysdeps/generic/abort.c:83
> #3  0x408685ed in TUnixSystem::Abort ()
> #4  0x408677fe in TUnixSystem::DispatchSignals ()
> #5  0x4086699f in SigHandler ()
> #6  0x40869560 in sighandler ()
> #7  <signal handler called>
> #8  0x4037f5c7 in G__ClassInfo::IsValid ()
> #9  0x403801c5 in G__ClassInfo::New ()
> #10 0x407523ad in TClass::New ()
> #11 0x402c5a8d in TBuffer::ReadObject ()
> #12 0x4031e6c0 in operator>> ()
> #13 0x404eea2a in TCollection::Streamer ()
> #14 0x4050dd99 in TSeqCollection::Streamer ()
> #15 0x4050d749 in TList::Streamer ()
> #16 0x402c5ae9 in TBuffer::ReadObject ()
> #17 0x4050d71c in operator>> ()
> #18 0x405ab74d in TPaveText::Streamer ()
> #19 0x403229e4 in TKey::Read ()
> #20 0x40328095 in TObject::Read ()
> #21 0x806b6bb in MainWindow::treatList (this=0xbffff7e4, id=2) at
> src/probe_mainwindow.cpp:526
> 
>   ------------------------------------------------------------------------
> 
>                                           Name: test_VI7_10.5.1999_10:15:47.root
>    test_VI7_10.5.1999_10:15:47.root       Type: unspecified type (APPLICATION/octet-stream)
>                                       Encoding: BASE64



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:32 MET