Re: root 4.03 and shared memories (TMapFile)

From: Diego Faso <faso_at_to.infn.it>
Date: Wed, 2 Mar 2005 16:40:00 +0100 (MET)


Thank you, I add an information: I tried to use an application linked to ROOTLIBS without linking lNew and using "rootcint" with the "-p" option: I can create shared memories and update them, but I can open them and get contained objects only by writing interpreted - not compiled - instructions.
I will wait for news. Cheers.
Diego

On Wed, 2 Mar 2005, Rene BRUN wrote:

> Hi Diego,
>
> We can reproduce this problem with TMapFile under SLC3 or FC3.
> We will investigate
>
> Rene Brun
>
> Diego Faso wrote:
> > Hello, I'm using root-4.03/03 on linux Fedora Core-3 (gcc 3.4.2 20041017).
> >
> > I'm trying to use the TMapFile class as described in the root tutorials
> > (see attached macros). These macros work correctly with root-3.10/02 on
> > Scientific Linux-3.03 (gcc 3.2.3 20030502), but only if I use the
> > "rootn.exe" executable instead of "root".
> >
> > When I try to run the producer on root-4.03/03 I obtain the output
> > reported in the end of this message (complete stack trace).
> > I tried to comment the line "mfile->Update();" in the producer source
> > code and the producer runs, but the consumer can't find anything inside
> > the "mapfile".
> >
> > I thank you in advance for you help, cheers
> > Diego
> >
> > ---------------------------------------------------------------
> >
> > root [0] .x Producer1.C++
> > Info in <TUnixSystem::ACLiC>: creating shared library
> > /home/finuda/root_tests/SharedMemories/./Producer1_C.so
> > mfile is: 0xf5879008
> > Memory mapped file: hsimple.map
> > Title: Demo memory mapped file with histograms
> > Option: CREATE
> > Mapped Memory region: 0xf5875000 - 0xf588e000 (0.10 MB)
> > Current breakval: 0xf587d000
> > Object Class Size
> > hpx (null) 0
> > hpxpy (null) 0
> > hprof (null) 0
> >
> > *** Break *** illegal instruction
> > Generating stack trace...
> > /usr/bin/addr2line: 'rootn.exe': No such file
> > /usr/bin/addr2line: 'rootn.exe': No such file
> > 0xf588fa26 in <unknown function>
> > 0xf588fb40 in <unknown function>
> > 0xf67cd506 in G__call_cppfunc + 0x264 from
> > /usr/local/fndprg/root/lib/libCint.so
> > 0xf67bc313 in G__interpret_func + 0x7ac from
> > /usr/local/fndprg/root/lib/libCint.so
> > 0xf679f953 in G__getfunction + 0x1bd5 from
> > /usr/local/fndprg/root/lib/libCint.so
> > 0xf6795931 in G__getitem + 0x656 from
> > /usr/local/fndprg/root/lib/libCint.so
> > 0xf679420e in G__getexpr + 0x834e from
> > /usr/local/fndprg/root/lib/libCint.so
> > 0xf678bb6b in G__calc_internal + 0x2c8 from
> > /usr/local/fndprg/root/lib/libCint.so
> > 0xf67f2598 in G__process_cmd + 0x22dc from
> > /usr/local/fndprg/root/lib/libCint.so
> > 0xf6af13b1 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*)
> > + 0xaf from /usr/local/fndprg/root/lib/libCore.so
> > 0xf6af14bc in TCint::ProcessLineSynch(char const*,
> > TInterpreter::EErrorCode*) + 0x46 from
> > /usr/local/fndprg/root/lib/libCore.so
> > 0xf6a48c42 in TApplication::ProcessFile(char const*, int*) + 0x6fa from
> > /usr/local/fndprg/root/lib/libCore.so
> > 0xf6a484cd in TApplication::ProcessLine(char const*, bool, int*) + 0x623
> > from /usr/local/fndprg/root/lib/libCore.so
> > 0xf5f1ef30 in TRint::HandleTermInput() + 0x234 from
> > /usr/local/fndprg/root/lib/libRint.so
> > 0xf5f1dbbe in TTermInputHandler::Notify() + 0x24 from
> > /usr/local/fndprg/root/lib/libRint.so
> > 0xf5f1f3ac in TTermInputHandler::ReadNotify() + 0x12 from
> > /usr/local/fndprg/root/lib/libRint.so
> > 0xf6b96ae6 in TUnixSystem::CheckDescriptors() + 0x152 from
> > /usr/local/fndprg/root/lib/libCore.so
> > 0xf6b959ec in TUnixSystem::DispatchOneEvent(bool) + 0x184 from
> > /usr/local/fndprg/root/lib/libCore.so
> > 0xf6ab13e2 in TSystem::InnerLoop() + 0x18 from
> > /usr/local/fndprg/root/lib/libCore.so
> > 0xf6ab1382 in TSystem::Run() + 0x7a from
> > /usr/local/fndprg/root/lib/libCore.so
> > 0xf6a48d74 in TApplication::Run(bool) + 0x32 from
> > /usr/local/fndprg/root/lib/libCore.so
> > 0xf5f1e96c in TRint::Run(bool) + 0x364 from
> > /usr/local/fndprg/root/lib/libRint.so
> > 0x08048d3b in main + 0x67 from rootn.exe
> > 0x00868e33 in __libc_start_main + 0xe3 from /lib/tls/libc.so.6
> > 0x08048c4d in TApplicationImp::ShowMembers(TMemberInspector&, char*) +
> > 0x31 from rootn.exe
> > Root >
> > *** Break *** segmentation violation
> > Generating stack trace...
> > 0xf588e024 in <unknown function>
> > Root > Segmentation fault
> >
> >
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > #include <Riostream.h>
> > #include "TH1F.h"
> > #include "TH2F.h"
> > #include "TProfile.h"
> > #include "TRandom.h"
> > #include "TMapFile.h"
> >
> > void Producer1(){
> > // Histogram producer script. This script creates a memory mapped
> > // file and stores three histogram objects in it (a TH1F, a TH2F and a
> > // TProfile). It then fills, in an infinite loop (so use ctrl-c to
> > // stop this script), the three histogram objects with random numbers.
> > // Every 10 fills the objects are updated in shared memory.
> > // Use the hcons.C script to map this file and display the histograms.
> >
> > gROOT->Reset();
> >
> > // Create a new memory mapped file. The memory mapped file can be
> > // opened in an other process on the same machine and the objects
> > // stored in it can be accessed.
> >
> > TMapFile *mfile = TMapFile::Create("hsimple.map","RECREATE", 100000,
> > "Demo memory mapped file with histograms");
> >
> > cout << "mfile is: " << mfile << endl;
> > // Create a 1d, a 2d and a profile histogram. These objects will
> > // be automatically added to the current directory, i.e. mfile.
> > TH1F *hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
> > TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
> > TProfile *hprof = new TProfile("hprof","Profile of pz versus px",100,-4,4,0,20);
> >
> > // Set a fill color for the TH1F
> > hpx->SetFillColor(48);
> > // Print status of mapped file
> > mfile->Print();
> > mfile->ls();
> >
> > // Endless loop filling histograms with random numbers
> > Float_t px, py, pz;
> > int ii = 0;
> > while (1) {
> > gRandom->Rannor(px,py);
> > pz = px*px + py*py;
> > hpx->Fill(px);
> > hpxpy->Fill(px,py);
> > hprof->Fill(px,pz);
> > if (!(ii % 10)) {
> > mfile->Update(); // updates all objects in shared memory
> > if (!ii) mfile->ls(); // print contents of mapped file after
> > } // first update
> > ii++;
> > }
> > }
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > #include <Riostream.h>
> > #include "TROOT.h"
> > #include "TSystem.h"
> > #include "TCanvas.h"
> > #include "TH1F.h"
> > #include "TH2F.h"
> > #include "TProfile.h"
> > #include "TRandom.h"
> > #include "TMapFile.h"
> >
> > void Consumer1(){
> > // Histogram consumer script. Create a canvas and 3 pads. Connect
> > // to memory mapped file "hsimple.map", that was created by hprod.C.
> > // It reads the histograms from shared memory and displays them
> > // in the pads (sleeping for 0.1 seconds before starting a new read-out
> > // cycle). This script runs in an infinite loop, so use ctrl-c to stop it.
> >
> > gROOT->Reset();
> >
> > // Create a new canvas and 3 pads
> > TCanvas *c1;
> > TPad *pad1, *pad2, *pad3;
> > if (!gROOT->IsBatch()) {
> > c1 = new TCanvas("c1","Shared Memory Consumer Example",200,10,700,780);
> > pad1 = new TPad("pad1","This is pad1",0.02,0.52,0.98,0.98,21);
> > pad2 = new TPad("pad2","This is pad2",0.02,0.02,0.48,0.48,21);
> > pad3 = new TPad("pad3","This is pad3",0.52,0.02,0.98,0.48,21);
> > pad1->Draw();
> > pad2->Draw();
> > pad3->Draw();
> > }
> >
> > // Open the memory mapped file "hsimple.map" in "READ" (default) mode.
> > TMapFile *mfile = TMapFile::Create("hsimple.map");
> >
> > // Print status of mapped file and list its contents
> > mfile->Print();
> > mfile->ls();
> >
> > // Create pointers to the objects in shared memory.
> > TH1F *hpx = 0;
> > TH2F *hpxpy = 0;
> > TProfile *hprof = 0;
> >
> > // Loop displaying the histograms. Once the producer stops this
> > // script will break out of the loop.
> > Int_t oldentries = 0;
> > while (1) {
> > hpx = (TH1F *) mfile->Get("hpx", hpx);
> > hpxpy = (TH2F *) mfile->Get("hpxpy", hpxpy);
> > hprof = (TProfile *) mfile->Get("hprof", hprof);
> > if (hpx->GetEntries() == oldentries) break;
> > oldentries = (Int_t) hpx->GetEntries();
> > if (!gROOT->IsBatch()) {
> > pad1->cd();
> > hpx->Draw();
> > pad2->cd();
> > hprof->Draw();
> > pad3->cd();
> > hpxpy->Draw("cont");
> > c1->Modified();
> > c1->Update();
> > }
> > else {
> > printf("Entries, hpx=%d, Mean=%g, RMS=%g\n",hpx->GetEntries(),hpx->GetMean(),hpx->GetRMS());
> > }
> > gSystem->Sleep(100); // sleep for 0.1 seconds
> > }
> > }
> >
> >
>
Received on Wed Mar 02 2005 - 16:40:47 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET