Incomplete type in TString argument


ROOT Version: 6.18.04
Platform: CentOS Linux release 7.7.1908 (Core) (lxplus)
Compiler: gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)


Dear co-rooters,

I am facing a rather bizarre issue. I am processing some data and when adding a TH2F histogram I get a segmentation error. The only relevant info that I get concerns the second argument of my macro which is a TString

#17 0x00007fc97188f9fb in analyser (filename_in=..., filename_out=<incomplete type>) at /eos/home-a/astamato/./analyser_orela.C:268

This points out to the line where the histogram is written with the Write() function. When I change this histogram to a TH1F everything works fine but I don’t understand why. Note that I have enough quota to write the output root file. In addition I run the macro with valgrind to check if I have a memory leak somewhere, but I can’t find anything there as well. The output of valgrind is at the end of the post. My macro is the following

#include "TH1.h"
#include "TH2.h"
#include "TFile.h"
#include "TMath.h"
#include "TString.h"

#include <string>
#include <math.h>
#include <stdio.h>
using namespace std;

#pragma once
#include "header_parameters.h"

void analyser(TString filename_in, TString filename_out){

//_____________________________________________________________________________________________________________________
//(0) Usefull variables

	// Proton, bunch counting
	int number_T0s = 0;

	// Waiting time distributions
	float dt_2       = 0.   , dt_3       = 0.;
	float tof_prev_2 = 0.   , tof_prev_3 = 0.;
	bool  init_dt_2  = false, init_dt_3  = false;
	
	// Dead-time correction
	//float dead_time_2    = 500.; 
	//float dead_time_3    = 500.;
	float tof_prev_cut_2 = 0.;
	float tof_prev_cut_3 = 0.;
	
	// Misc
	float bin_content = 0.;
	
//_____________________________________________________________________________________________________________________	
//(1) Open the root file and loop over the TTree

	TFile *f_root = TFile::Open(filename_in);
	TTree *t = (TTree*)f_root->Get("DICER");

	float  tof, tof0, area_fast, area_slow;
	int    detn, RunNumber;
	
	int   detn_prev, RunNumber_prev;
	float tof_prev, tof0_prev, dt_23;

	t->SetBranchAddress("area_slow_THANOS", &area_slow);
	t->SetBranchAddress("RunNumber_THANOS", &RunNumber);
	t->SetBranchAddress("area_fast_THANOS", &area_fast);
	t->SetBranchAddress("tof0_THANOS"     , &tof0);
	t->SetBranchAddress("detn_THANOS"     , &detn);
	t->SetBranchAddress("tof_THANOS"      , &tof);

	int     entries = t->GetEntries();
	
	std::cout << "Total entries found: " << entries << std::endl;
	
	float	j = entries/100.;
	int 	n = 1;
	
	
//_____________________________________________________________________________________________________________________
//(2) Create neutron time binning

	int     T_MIN   = 0;
	int	    T_MAX   = 12;
	int	    ndec    = T_MAX - T_MIN;
	int     N_BPDEC = 1000;
	int	    nbins   = (int) ndec*N_BPDEC;
	double	step	= (double) ndec / nbins;
	double	tbins[nbins+1];

	for(int i=0; i <= nbins; ++i)
		tbins[i] = (float) pow(10., step * (double) i + T_MIN);
		
		
//_____________________________________________________________________________________________________________________		
//(3) Define the histograms

	//Detector 2 - One of the PMTs
	TH1F *h_tof_2        = new TH1F("h_tof_2"       , "Raw tof - PMT 2;                     TOF(ns);               Counts"              , nbins, tbins);
	TH1F *h_fast_2       = new TH1F("h_fast_2"      , "Fast area - PMT 2;                   Fast area (ADC units); Counts"              , 3.5e3, 0, 3.5e4);
	TH1F *h_slow_2       = new TH1F("h_slow_2"      , "Slow area - PMT 2;                   Slow area (ADC units); Counts"              , 7e3, 0, 7e4);
	TH1F *h_dt_2         = new TH1F("h_dt_2"        , "Waiting time - PMT 2;                Time difference(ns)  ; Counts"              , 1.e7, 0., 1.e8);
	TH1F *h_rate_2       = new TH1F("h_rate_2"      , "Counting Rate - PMT 2;               TOF (ns)             ; Counts/us/bunch"     , nbins, tbins);
	TH1F *h_tof_cut_2    = new TH1F("h_tof_cut_2"   , "Cut tof - PMT 2;                     TOF(ns);               Counts"              , nbins, tbins);
	TH2F *h_tof_dt_2     = new TH2F("h_tof_dt_2"    , "tof VS waiting time - PMT 2;         TOF(ns)              ; Waiting time"        , nbins, tbins, 1.e5, 0, 1.e6);
	TH2F *h_fast_slow_2  = new TH2F("h_fast_slow_2" , "Fast vs Slow area - PMT 2;           Fast area (ADC units); Slow area(ADC units)", 3.5e3, 0, 3.5e4, 7e3, 0, 7e4);
	TH2F *h_tof_fast_2   = new TH2F("h_tof_fast_2"  , "tof VS fast area - PMT 2;            TOF(ns);               Fast area(ADC units)", nbins, tbins, 3.5e3, 0, 3.5e4);
	TH2F *h_tof_slow_2   = new TH2F("h_tof_slow_2"  , "tof VS slow area - PMT 2;            TOF(ns);               Slow area(ADC units)", nbins, tbins, 7e3, 0, 7e4);
	
	//Detector 3 - The other PMT
	TH1F *h_tof_3        = new TH1F("h_tof_3"       , "Raw tof - PMT 3;                     TOF(ns);               Counts"              , nbins, tbins);
	TH1F *h_fast_3       = new TH1F("h_fast_3"      , "Fast area - PMT 3;                   Fast area (ADC units); Counts"              , 3.5e3, 0, 3.5e4);
	TH1F *h_slow_3       = new TH1F("h_slow_3"      , "Slow area - PMT 3;                   Slow area (ADC units); Counts"              , 7e3, 0, 7e4);
	TH1F *h_dt_3         = new TH1F("h_dt_3"        , "Waiting time - PMT 3;                Time difference(ns)  ; Counts"              , 1.e7, 0., 1.e8);
	TH1F *h_rate_3       = new TH1F("h_rate_3"      , "Counting Rate - PMT 3;               TOF (ns)             ; Counts/us/bunch"     , nbins, tbins);
	TH1F *h_tof_cut_3    = new TH1F("h_tof_cut_3"   , "Cut tof - PMT 3;                      TOF(ns);             Counts"              , nbins, tbins);
	//TH2F *h_tof_dt_3     = new TH2F("h_tof_dt_3"    , ""        , nbins, tbins, 1.e5, 0., 1.e6);
	TH2F *h_BAD = new TH2F("h_BAD","title", nbins, tbins, 1.e5, 0, 1.e6);
	TH2F *h_fast_slow_3  = new TH2F("h_fast_slow_3" , "Fast vs Slow area - PMT 3;           Fast area (ADC units); Slow area(ADC units)", 3.5e3, 0, 3.5e4, 7e3, 0, 7e4);
	TH2F *h_tof_fast_3   = new TH2F("h_tof_fast_3"  , "tof VS fast area - PMT 3;            TOF(ns);               Fast area(ADC units)", nbins, tbins, 3.5e3, 0, 3.5e4);
	TH2F *h_tof_slow_3   = new TH2F("h_tof_slow_3"  , "tof VS slow area - PMT 3;            TOF(ns);               Slow area(ADC units)", nbins, tbins, 7e3, 0, 7e4);
	
	//Detector 200 - The TO
	TH1F *h_tof_T0       = new TH1F("h_tof_T0"      , "Raw tof - T0;                        TOF(ns);               Counts"              , nbins, tbins);
	TH1F *h_fast_T0      = new TH1F("h_fast_T0"     , "Fast area - T0;                      Fast area (ADC units); Counts"              , 3.5e3, 0    , 3.5e4);
	TH1F *h_slow_T0      = new TH1F("h_slow_T0"     , "Slow area - T0;                      Slow area (ADC units); Counts"              , 7e3  , 0    , 7e4);
	TH2F *h_fast_slow_T0 = new TH2F("h_fast_slow_T0", "Fast vs Slow area - T0;              Fast area (ADC units); Slow area(ADC units)", 3.5e3, 0    , 3.5e4, 7e3, 0, 7e4);
	TH2F *h_tof_fast_T0  = new TH2F("h_tof_fast_T0" , "tof VS fast area - T0;               TOF(ns);               Fast area(ADC units)", nbins, tbins, 3.5e3, 0  , 3.5e4);
	TH2F *h_tof_slow_T0  = new TH2F("h_tof_slow_T0" , "tof VS slow area - T0;               TOF(ns);               Slow area(ADC units)", nbins, tbins, 7e3  , 0  , 7e4);
	
	// For the coincidneces
	TH1F *h_diff_2_3     = new TH1F("h_diff_2_3"   , "Difference 2 vs 3;                     Time (ns);             Counts"              , 200000, -100000, 100000);
	
	// For beam characteristics
	TH1F *h_number_T0    = new TH1F("h_number_T0"   , "Beam characteristics;                       AU                   ; Counts"              , 3    , 0    , 3  );

	n =1;
	printf("         10        20        30        40        50        60        70        80        90        100 %%\n");
	printf(" ---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|    \n");
	
	
//_____________________________________________________________________________________________________________________
// () Loop over the entries
	
	for (int i = 0; i < entries; ++i){
		if(i == 0) {cout << " ";}
		if(i >= n*j) {cout << '|' << flush; n++;}// Progress indicator


		t->GetEntry(i);
		
		//if (detn==200)
		//	newT0=true;
		//else
		//	newT0=false;
		
		// Apply the cuts here
		if (detn==1) continue;
		
		if (detn==2){
			h_tof_2       ->Fill(tof);
			h_fast_2      ->Fill(area_fast);
			h_slow_2      ->Fill(area_slow);
			h_fast_slow_2 ->Fill(area_fast, area_slow);
			h_tof_fast_2  ->Fill(tof, area_fast);
			h_tof_slow_2  ->Fill(tof, area_slow);
		}//_detn==2
		
		if (detn==3){
			h_tof_3       ->Fill(tof);
			h_fast_3      ->Fill(area_fast);
			h_slow_3      ->Fill(area_slow);
			h_fast_slow_3 ->Fill(area_fast, area_slow);
			h_tof_fast_3  ->Fill(tof, area_fast);
			h_tof_slow_3  ->Fill(tof, area_slow);
		}//_detn==3
		
		if (detn==200){
//			h_T0          ->Fill(tof);
			h_tof_T0      ->Fill(tof);
			h_fast_T0     ->Fill(area_fast);
			h_slow_T0     ->Fill(area_slow);
			h_fast_slow_T0->Fill(area_fast, area_slow);
			h_tof_fast_T0 ->Fill(tof, area_fast);
			h_tof_slow_T0 ->Fill(tof, area_slow);
			number_T0s++;
		}//_detn==200
		
		
//_____________________________________________________________________________________________________________________		
// () Calculate waiting time distributions

		if(detn==200){
			if(tof_prev_cut_2!=0)
				h_tof_cut_2->Fill(tof_prev_cut_2);
			if(tof_prev_cut_3!=0)
				h_tof_cut_3->Fill(tof_prev_cut_3);
			init_dt_2      = false;
			init_dt_3      = false;
			dt_2           = 0.;
			dt_3           = 0.;
			tof_prev_2     = 0.;
			tof_prev_3     = 0.;
			tof_prev_cut_2 = 0.;
			tof_prev_cut_3 = 0.;
		}
			
		if (detn==2){
			if(init_dt_2){
				dt_2       = tof - tof_prev_2;
				h_dt_2    -> Fill(dt_2);
				h_tof_dt_2-> Fill(tof_prev_2, dt_2);
				tof_prev_2 = tof;
				if (tof-tof_prev_cut_2 > dead_time_2){
					h_tof_cut_2->Fill(tof_prev_cut_2);
					tof_prev_cut_2 = tof;
				}
			}
			else{
				tof_prev_2     = tof;
				init_dt_2      = true;
				tof_prev_cut_2 = tof;
			}
		}
		
		if (detn==3){
			if(init_dt_3){
				dt_3       = tof - tof_prev_3;
				h_dt_3    -> Fill(dt_3);
				//h_tof_dt_3-> Fill(tof_prev_3, dt_3);
				tof_prev_3 = tof;
				if (tof-tof_prev_cut_3 > dead_time_3){
					h_tof_cut_3->Fill(tof_prev_cut_3);
					tof_prev_cut_3 = tof;
				}
			}
			else{
				tof_prev_3     = tof;
				init_dt_3      = true;
				tof_prev_cut_3 = tof;
			}
		}	
		
	}//_loop over entries
	std::cout << std::endl;



//_____________________________________________________________________________________________________________________	
// (3) Store beam properties

	std::cout << "Found " << number_T0s << " T0s" << std::endl;
	h_number_T0->SetBinContent(1, number_T0s);


//_____________________________________________________________________________________________________________________	
// (4) Calculate the counting rates in 

	for (int i=0; i<h_tof_2->GetNbinsX(); ++i){
		// det 2
		bin_content = h_tof_2->GetBinContent(i+1)/h_tof_2->GetBinWidth(i+1); // Counting rate (counts/ns [GHz])
		bin_content = bin_content*1000./number_T0s;                          // Counting rate (MHz/bunch)
		h_rate_2->SetBinContent(i+1, bin_content);
		// det 3
		bin_content = h_tof_3->GetBinContent(i+1)/h_tof_3->GetBinWidth(i+1); // Counting rate (counts/ns [GHz])
		bin_content = bin_content*1000./number_T0s;                          // Counting rate (MHz/bunch)
		h_rate_3->SetBinContent(i+1, bin_content);
	}


//_____________________________________________________________________________________________________________________	
// (4) Save the histograms in a root file
	
	TFile *fout = new TFile(filename_out, "RECREATE");
		h_tof_2       ->Write();
		h_fast_2      ->Write();
		h_slow_2      ->Write();
		h_rate_2      ->Write();
		h_dt_2        ->Write();
		h_tof_cut_2   ->Write();
		h_tof_dt_2    ->Write();
		h_fast_slow_2 ->Write();
		h_tof_fast_2  ->Write();
		h_tof_slow_2  ->Write();
		//
		h_tof_3       ->Write();
		h_fast_3      ->Write();
		h_slow_3      ->Write();
		h_rate_3      ->Write();
		h_dt_3        ->Write();
		h_tof_cut_3   ->Write();
		//h_tof_dt_3    ->Write();
		h_BAD->Write();
		h_fast_slow_3 ->Write();
		h_tof_fast_3  ->Write();
		h_tof_slow_3  ->Write();
		//
		h_tof_T0      ->Write();
		h_fast_T0     ->Write();
		h_slow_T0     ->Write();
		h_fast_slow_T0->Write();
		h_tof_fast_T0 ->Write();
		h_tof_slow_T0 ->Write();
		h_number_T0  ->Write();
		//
		h_diff_2_3    ->Write();
		
		//h_tof_dt_3    ->Write();
	fout->Close();
}

header_parameters.h

float dead_time_2 = 2000.;
float dead_time_3 = 2000.;

Any idea on what might be the issue? Thanks in advance!


[astamato@lxplus700 coincidence_ORELA]$ valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all -v root -b -l
==5623== Memcheck, a memory error detector
==5623== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==5623== Using Valgrind-3.14.0-353a3587bb-20181007X and LibVEX; rerun with -h for copyright info
==5623== Command: root -b -l
==5623== 
--5623-- Valgrind options:
--5623--    --tool=memcheck
--5623--    --leak-check=full
--5623--    --show-leak-kinds=all
--5623--    -v
--5623-- Contents of /proc/version:
--5623--   Linux version 3.10.0-1062.12.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Feb 4 23:02:59 UTC 2020
--5623-- 
--5623-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-avx-avx2-bmi
--5623-- Page sizes: currently 4096, max supported 4096
--5623-- Valgrind library directory: /usr/lib64/valgrind
--5623-- Reading syms from /usr/bin/root
--5623--    object doesn't have a symbol table
--5623-- Reading syms from /usr/lib64/ld-2.17.so
--5623-- Reading syms from /usr/lib64/valgrind/memcheck-amd64-linux
--5623--    object doesn't have a symbol table
--5623--    object doesn't have a dynamic symbol table
--5623-- Scheduler: using generic scheduler lock implementation.
--5623-- Reading suppressions file: /usr/lib64/valgrind/default.supp
==5623== embedded gdbserver: reading from /tmp/astamato/vgdb-pipe-from-vgdb-to-5623-by-astamato-on-lxplus700.cern.ch
==5623== embedded gdbserver: writing to   /tmp/astamato/vgdb-pipe-to-vgdb-from-5623-by-astamato-on-lxplus700.cern.ch
==5623== embedded gdbserver: shared mem   /tmp/astamato/vgdb-pipe-shared-mem-vgdb-5623-by-astamato-on-lxplus700.cern.ch
==5623== 
==5623== TO CONTROL THIS PROCESS USING vgdb (which you probably
==5623== don't want to do, unless you know exactly what you're doing,
==5623== or are doing some strange experiment):
==5623==   /usr/lib64/valgrind/../../bin/vgdb --pid=5623 ...command...
==5623== 
==5623== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==5623==   /path/to/gdb root
==5623== and then give GDB the following command
==5623==   target remote | /usr/lib64/valgrind/../../bin/vgdb --pid=5623
==5623== --pid is optional if only one valgrind process is running
==5623== 
--5623-- REDIR: 0x4019df0 (ld-linux-x86-64.so.2:strlen) redirected to 0x580c66c5 (???)
--5623-- REDIR: 0x4019bc0 (ld-linux-x86-64.so.2:index) redirected to 0x580c66df (???)
--5623-- Reading syms from /usr/lib64/valgrind/vgpreload_core-amd64-linux.so
--5623-- Reading syms from /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so
==5623== WARNING: new redirection conflicts with existing -- ignoring it
--5623--     old: 0x04019df0 (strlen              ) R-> (0000.0) 0x580c66c5 ???
--5623--     new: 0x04019df0 (strlen              ) R-> (2007.0) 0x04c2d0e0 strlen
--5623-- REDIR: 0x4019d70 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4c2e230 (strcmp)
--5623-- REDIR: 0x401aa30 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4c31de0 (mempcpy)
--5623-- Reading syms from /usr/lib64/libXpm.so.4.11.0
--5623--    object doesn't have a symbol table
--5623-- Reading syms from /usr/lib64/libX11.so.6.3.0
--5623--    object doesn't have a symbol table
--5623-- Reading syms from /usr/lib64/libXext.so.6.4.0
--5623--    object doesn't have a symbol table
--5623-- Reading syms from /usr/lib64/libstdc++.so.6.0.19
--5623--    object doesn't have a symbol table
--5623-- Reading syms from /usr/lib64/libgcc_s-4.8.5-20150702.so.1
--5623--    object doesn't have a symbol table
--5623-- Reading syms from /usr/lib64/libpthread-2.17.so
--5623-- Reading syms from /usr/lib64/libc-2.17.so
--5623-- Reading syms from /usr/lib64/libxcb.so.1.1.0
--5623--    object doesn't have a symbol table
--5623-- Reading syms from /usr/lib64/libdl-2.17.so
--5623-- Reading syms from /usr/lib64/libm-2.17.so
--5623-- Reading syms from /usr/lib64/libXau.so.6.0.0
--5623--    object doesn't have a symbol table
--5623-- REDIR: 0x5d620e0 (libc.so.6:strcasecmp) redirected to 0x4a247a0 (_vgnU_ifunc_wrapper)
--5623-- REDIR: 0x5d5ee60 (libc.so.6:strnlen) redirected to 0x4a247a0 (_vgnU_ifunc_wrapper)
--5623-- REDIR: 0x5d643b0 (libc.so.6:strncasecmp) redirected to 0x4a247a0 (_vgnU_ifunc_wrapper)
--5623-- REDIR: 0x5d618c0 (libc.so.6:memset) redirected to 0x4a247a0 (_vgnU_ifunc_wrapper)
--5623-- REDIR: 0x5d61870 (libc.so.6:memcpy@GLIBC_2.2.5) redirected to 0x4a247a0 (_vgnU_ifunc_wrapper)
--5623-- REDIR: 0x5d5ed80 (libc.so.6:__GI_strlen) redirected to 0x4c2d040 (__GI_strlen)
--5623-- REDIR: 0x5d60850 (libc.so.6:__GI_strrchr) redirected to 0x4c2caa0 (__GI_strrchr)
--5623-- REDIR: 0x5d5ef80 (libc.so.6:__GI_strncmp) redirected to 0x4c2d870 (__GI_strncmp)
--5646-- REDIR: 0x55f7fc0 (libstdc++.so.6:operator new[](unsigned long)) redirected to 0x4c2aae1 (operator new[](unsigned long))
--5646-- REDIR: 0x5d68370 (libc.so.6:strchrnul) redirected to 0x4c31900 (strchrnul)
--5646-- REDIR: 0x5d57eb0 (libc.so.6:free) redirected to 0x4c2af16 (free)
root [0] .L analyser_orela.C++
Info in <TUnixSystem::ACLiC>: creating shared library /eos/home-a/astamato/./analyser_orela_C.so
root [1] analyser("orela_21768_21769.root.raw", "0_test_2000ns.root")
Total entries found: 7444905
         10        20        30        40        50        60        70        80        90        100 %
 ---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|    
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Found 1783532 T0s

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
    gdb.printing.register_pretty_printer(gdb.current_objfile(),
    gdb.printing.register_pretty_printer(gdb.current_objfile(),
#0  0x00007fc983e0441c in waitpid () from /lib64/libc.so.6
#1  0x00007fc983d81f12 in do_system () from /lib64/libc.so.6
#2  0x00007fc984974644 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.6.18
#3  0x00007fc98497648c in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.6.18
#4  <signal handler called>
#5  0x00007fc981a62f30 in TBufferFile::WriteFastArray(float const*, int) () from /usr/lib64/root/libRIO.so
#6  0x00007fc9848c6ac4 in TArrayF::Streamer(TBuffer&) () from /usr/lib64/root/libCore.so.6.18
#7  0x00007fc984956b4b in TStreamerBase::WriteBuffer(TBuffer&, char*) () from /usr/lib64/root/libCore.so.6.18
#8  0x00007fc981cc961d in int TStreamerInfo::WriteBufferAux<char**>(TBuffer&, char** const&, TStreamerInfo::TCompInfo* const*, int, int, int, int, int) () from /usr/lib64/root/libRIO.so
#9  0x00007fc981b1156d in TStreamerInfoActions::GenericWriteAction(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) () from /usr/lib64/root/libRIO.so
#10 0x00007fc981a675d5 in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) () from /usr/lib64/root/libRIO.so
#11 0x00007fc981a67a7c in TBufferFile::WriteClassBuffer(TClass const*, void*) () from /usr/lib64/root/libRIO.so
#12 0x00007fc9756b9fa8 in TH2F::Streamer(TBuffer&) () from /usr/lib64/root/libHist.so.6.18.04
#13 0x00007fc981af0923 in TKey::TKey(TObject const*, char const*, int, TDirectory*) () from /usr/lib64/root/libRIO.so
#14 0x00007fc981ab3075 in TFile::CreateKey(TDirectory*, TObject const*, char const*, int) () from /usr/lib64/root/libRIO.so
#15 0x00007fc981aa6adf in TDirectoryFile::WriteTObject(TObject const*, char const*, char const*, int) () from /usr/lib64/root/libRIO.so
#16 0x00007fc9848735df in TObject::Write(char const*, int, int) const () from /usr/lib64/root/libCore.so.6.18
#17 0x00007fc97188f9fb in analyser (filename_in=..., filename_out=<incomplete type>) at /eos/home-a/astamato/./analyser_orela.C:268
#18 0x00007fc9850b608a in ?? ()
#19 0x0000000000000000 in ?? ()
===========================================================


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  0x00007fc981a62f30 in TBufferFile::WriteFastArray(float const*, int) () from /usr/lib64/root/libRIO.so
#6  0x00007fc9848c6ac4 in TArrayF::Streamer(TBuffer&) () from /usr/lib64/root/libCore.so.6.18
#7  0x00007fc984956b4b in TStreamerBase::WriteBuffer(TBuffer&, char*) () from /usr/lib64/root/libCore.so.6.18
#8  0x00007fc981cc961d in int TStreamerInfo::WriteBufferAux<char**>(TBuffer&, char** const&, TStreamerInfo::TCompInfo* const*, int, int, int, int, int) () from /usr/lib64/root/libRIO.so
#9  0x00007fc981b1156d in TStreamerInfoActions::GenericWriteAction(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) () from /usr/lib64/root/libRIO.so
#10 0x00007fc981a675d5 in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) () from /usr/lib64/root/libRIO.so
#11 0x00007fc981a67a7c in TBufferFile::WriteClassBuffer(TClass const*, void*) () from /usr/lib64/root/libRIO.so
#12 0x00007fc9756b9fa8 in TH2F::Streamer(TBuffer&) () from /usr/lib64/root/libHist.so.6.18.04
#13 0x00007fc981af0923 in TKey::TKey(TObject const*, char const*, int, TDirectory*) () from /usr/lib64/root/libRIO.so
#14 0x00007fc981ab3075 in TFile::CreateKey(TDirectory*, TObject const*, char const*, int) () from /usr/lib64/root/libRIO.so
#15 0x00007fc981aa6adf in TDirectoryFile::WriteTObject(TObject const*, char const*, char const*, int) () from /usr/lib64/root/libRIO.so
#16 0x00007fc9848735df in TObject::Write(char const*, int, int) const () from /usr/lib64/root/libCore.so.6.18
#17 0x00007fc97188f9fb in analyser (filename_in=..., filename_out=<incomplete type>) at /eos/home-a/astamato/./analyser_orela.C:268
#18 0x00007fc9850b608a in ?? ()
#19 0x0000000000000000 in ?? ()
===========================================================


Root > 
root [2] .q
*** Error in `/usr/bin/root.exe': free(): invalid pointer: 0x00007fc70c8cf010 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x81679)[0x7fc983dc0679]
/usr/lib64/root/libCore.so.6.18(_ZN7TArrayFD1Ev+0x20)[0x7fc9848c6960]
/usr/lib64/root/libHist.so.6.18.04(_ZN4TH2FD1Ev+0x55)[0x7fc9756af9a5]
/usr/lib64/root/libHist.so.6.18.04(_ZN4TH2FD0Ev+0x9)[0x7fc9756af9f9]
/usr/lib64/root/libCore.so.6.18(_ZN9THashList6DeleteEPKc+0x46f)[0x7fc9848d959f]
/usr/lib64/root/libCore.so.6.18(_ZN5TROOT20EndOfProcessCleanupsEv+0xc6)[0x7fc98482d786]
/usr/lib64/root/libCore.so.6.18(_ZN11TUnixSystem4ExitEib+0x21)[0x7fc9849705b1]
/usr/lib64/root/libCore.so.6.18(_ZN12TApplication9TerminateEi+0x63)[0x7fc98483b283]
/usr/lib64/root/libCore.so.6.18(_ZN12TApplication11ProcessLineEPKcbPi+0x8f)[0x7fc98483965f]
/usr/lib64/root/libRint.so.6.18(_ZN5TRint13ProcessLineNrEPKcS1_Pi+0x155)[0x7fc984ca3195]
/usr/lib64/root/libRint.so.6.18(_ZN5TRint15HandleTermInputEv+0x23b)[0x7fc984ca347b]
/usr/lib64/root/libCore.so.6.18(_ZN11TUnixSystem16CheckDescriptorsEv+0x165)[0x7fc984975955]
/usr/lib64/root/libCore.so.6.18(_ZN11TUnixSystem16DispatchOneEventEb+0xda)[0x7fc984976bfa]
/usr/lib64/root/libCore.so.6.18(_ZN7TSystem9InnerLoopEv+0x16)[0x7fc984899bc6]
/usr/lib64/root/libCore.so.6.18(_ZN7TSystem3RunEv+0x70)[0x7fc98489ab10]
/usr/lib64/root/libCore.so.6.18(_ZN12TApplication3RunEb+0x1f)[0x7fc984837f5f]
/usr/lib64/root/libRint.so.6.18(_ZN5TRint3RunEb+0x389)[0x7fc984ca4af9]
/usr/bin/root.exe[0x4008ca]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7fc983d61505]
/usr/bin/root.exe[0x400928]
======= Memory map: ========
00400000-00401000 r-xp 00000000 fc:02 9916936                            /usr/bin/root.exe
00600000-00601000 r--p 00000000 fc:02 9916936                            /usr/bin/root.exe
00601000-00602000 rw-p 00001000 fc:02 9916936                            /usr/bin/root.exe
01a08000-06de7000 rw-p 00000000 00:00 0                                  [heap]
7fc6c4be3000-7fc82ab4d000 rw-p 00000000 00:00 0 
7fc96c000000-7fc96c021000 rw-p 00000000 00:00 0 
7fc96c021000-7fc970000000 ---p 00000000 00:00 0 
7fc97188d000-7fc971892000 r-xp 00000000 00:59 150185711763456000         /eos/home-a/astamato/analyser_orela_C.so
7fc971892000-7fc971a91000 ---p 00005000 00:59 150185711763456000         /eos/home-a/astamato/analyser_orela_C.so
7fc971a91000-7fc971a92000 r--p 00004000 00:59 150185711763456000         /eos/home-a/astamato/analyser_orela_C.so
7fc971a92000-7fc971a93000 rw-p 00005000 00:59 150185711763456000         /eos/home-a/astamato/analyser_orela_C.so
7fc971a93000-7fc971a9c000 r-xp 00000000 fc:02 69215364                   /usr/lib64/root/libMultiProc.so.6.18.04
7fc971a9c000-7fc971c9c000 ---p 00009000 fc:02 69215364                   /usr/lib64/root/libMultiProc.so.6.18.04
7fc971c9c000-7fc971c9d000 r--p 00009000 fc:02 69215364                   /usr/lib64/root/libMultiProc.so.6.18.04
7fc971c9d000-7fc971c9e000 rw-p 0000a000 fc:02 69215364                   /usr/lib64/root/libMultiProc.so.6.18.04
7fc971c9e000-7fc971de4000 r-xp 00000000 fc:02 69215369                   /usr/lib64/root/libTreePlayer.so.6.18.04
7fc971de4000-7fc971fe4000 ---p 00146000 fc:02 69215369                   /usr/lib64/root/libTreePlayer.so.6.18.04
7fc971fe4000-7fc971fef000 r--p 00146000 fc:02 69215369                   /usr/lib64/root/libTreePlayer.so.6.18.04
7fc971fef000-7fc971ff1000 rw-p 00151000 fc:02 69215369                   /usr/lib64/root/libTreePlayer.so.6.18.04
7fc971ff1000-7fc971ff9000 rw-p 00000000 00:00 0 
7fc971ff9000-7fc972034000 r-xp 00000000 fc:02 4839818                    /usr/lib64/libquadmath.so.0.0.0
7fc972034000-7fc972233000 ---p 0003b000 fc:02 4839818                    /usr/lib64/libquadmath.so.0.0.0
7fc972233000-7fc972234000 r--p 0003a000 fc:02 4839818                    /usr/lib64/libquadmath.so.0.0.0
7fc972234000-7fc972235000 rw-p 0003b000 fc:02 4839818                    /usr/lib64/libquadmath.so.0.0.0
7fc972235000-7fc972354000 r-xp 00000000 fc:02 4839820                    /usr/lib64/libgfortran.so.3.0.0
7fc972354000-7fc972554000 ---p 0011f000 fc:02 4839820                    /usr/lib64/libgfortran.so.3.0.0
7fc972554000-7fc972555000 r--p 0011f000 fc:02 4839820                    /usr/lib64/libgfortran.so.3.0.0
7fc972555000-7fc972557000 rw-p 00120000 fc:02 4839820                    /usr/lib64/libgfortran.so.3.0.0
7fc972557000-7fc972f96000 r-xp 00000000 fc:02 184597602                  /usr/lib64/atlas/libsatlas.so.3.10
7fc972f96000-7fc973196000 ---p 00a3f000 fc:02 184597602                  /usr/lib64/atlas/libsatlas.so.3.10
7fc973196000-7fc97319b000 r--p 00a3f000 fc:02 184597602                  /usr/lib64/atlas/libsatlas.so.3.10
7fc97319b000-7fc9731a4000 rw-p 00a44000 fc:02 184597602                  /usr/lib64/atlas/libsatlas.so.3.10
7fc9731a4000-7fc9731e0000 r-xp 00000000 fc:02 4874824                    /usr/lib64/libgslcblas.so.0.0.0
7fc9731e0000-7fc9733df000 ---p 0003c000 fc:02 4874824                    /usr/lib64/libgslcblas.so.0.0.0
7fc9733df000-7fc9733e0000 r--p 0003b000 fc:02 4874824                    /usr/lib64/libgslcblas.so.0.0.0
7fc9733e0000-7fc9733e1000 rw-p 0003c000 fc:02 4874824                    /usr/lib64/libgslcblas.so.0.0.0
7fc9733e1000-7fc9735f6000 r-xp 00000000 fc:02 4874822                    /usr/lib64/libgsl.so.0.16.0
7fc9735f6000-7fc9737f6000 ---p 00215000 fc:02 4874822                    /usr/lib64/libgsl.so.0.16.0
7fc9737f6000-7fc9737f9000 r--p 00215000 fc:02 4874822                    /usr/lib64/libgsl.so.0.16.0
7fc9737f9000-7fc973809000 rw-p 00218000 fc:02 4874822                    /usr/lib64/libgsl.so.0.16.0
7fc973809000-7fc97380a000 rw-p 00000000 00:00 0 
7fc97380a000-7fc97389a000 r-xp 00000000 fc:02 69215522                   /usr/lib64/root/libMathMore.so.6.18.04
7fc97389a000-7fc973a9a000 ---p 00090000 fc:02 69215522                   /usr/lib64/root/libMathMore.so.6.18.04
7fc973a9a000-7fc973a9f000 r--p 00090000 fc:02 69215522                   /usr/lib64/root/libMathMore.so.6.18.04
7fc973a9f000-7fc973aa1000 rw-p 00095000 fc:02 69215522                   /usr/lib64/root/libMathMore.so.6.18.04
7fc973aa1000-7fc973aa6000 rw-p 00000000 00:00 0 
7fc973aa6000-7fc973b42000 r-xp 00000000 fc:02 69215113                   /usr/lib64/root/libGraf3d.so.6.18.04
7fc973b42000-7fc973d42000 ---p 0009c000 fc:02 69215113                   /usr/lib64/root/libGraf3d.so.6.18.04
7fc973d42000-7fc973d4c000 r--p 0009c000 fc:02 69215113                   /usr/lib64/root/libGraf3d.so.6.18.04
7fc973d4c000-7fc973d4e000 rw-p 000a6000 fc:02 69215113                   /usr/lib64/root/libGraf3d.so.6.18.04
7fc973d4e000-7fc973d52000 rw-p 00000000 00:00 0 
7fc973d52000-7fc973d56000 r-xp 00000000 fc:02 2242564                    /usr/lib64/libuuid.so.1.3.0
--5623-- REDIR: 0x5d57eb0 (libc.so.6:free) redirected to 0x4c2af16 (free)
==5623== 
==5623== HEAP SUMMARY:
==5623==     in use at exit: 0 bytes in 0 blocks
==5623==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==5623== 
==5623== All heap blocks were freed -- no leaks are possible
==5623== 
==5623== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==5623== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Note that valgrind need to be run on root.exe to give useful information.
To a memory over-write error you do not need (nor want) the leak check

valgrind --tool=memcheck -v root .exe-b -l

Cheers,
Philippe.

Oh thanks a lot for that! The output now makes more sense, however I don’t understand where the problem is.

https://pastebin.com/tt57130w

Indeed you are flooded with false negative. You need to also add
--suppressions=$ROOTSYS/etc/valgrind-root.supp
to the valgrind invocation.

Thanks a lot for that!

That’s the new output

https://pastebin.com/R4qY6vGX

But I still can’t figure out what is the matter.

You may or may not be running of memory. One of the element of the error is:

==15748==  Address 0x2eeecdd9c is 519,421,276 bytes inside a block of size 519,421,277 alloc'd
==15748==    at 0x4C2AB68: operator new[](unsigned long) (vg_replace_malloc.c:433)
...
==15748==    by 0x17BB4FA7: TH2F::Streamer(TBuffer&) (in /usr/lib64/root/libHist.so.6.18.04)
==15748==    by 0x830D922: TKey::TKey(TObject const*, char const*, int, TDirectory*) (in /usr/lib64/root/libRIO.so.6.18.04)

Meaning that either the I/O library is confused or one of your histogram is using at 520MB of memory …

That is odd…
I have defined another histogram with exactly the same bins and it doesn’t seem to be a problem

TH2F *h_tof_dt_2 = new TH2F("h_tof_dt_2" , "tof VS waiting time - PMT 2; TOF(ns) ; Waiting time" , nbins, tbins, 1.e5, 0, 1.e6);

If you remove the 2nd one, does the 1st one still fail?

No it doesn’t!
That’s what’s odd!

I reduced the bins of some histograms to have a total size of less than 4MB, but I still get the same behaviour to the point that the histogram is being written.

What’s also strange is that I get something about an inconsistent type on the second argument

#17 0x00007fd7fd7959fb in analyser (filename_in=..., filename_out=<incomplete type>) at /eos/home-a/astamato/LANL/coincidence_ORELA/./analyser_orela.C:268

The ‘incomplete’ type is something amiss with the debugging symbol. Either they were not produced for some for code (ROOT or yours) … or there is a build mismatch …

I am not sure how to check.
But as far I understand, that’s not a hint to see what’s the matter.

the best way forward is likely for you to provide a complete running (and failing example) so I can try to reproduce the failure locally.

That can work!
Thanks a lot!!

Here is a link to a working directory.

https://cernbox.cern.ch/index.php/s/xWxEoyFOZRp2xyD

Thank you very much in advance!
The strange histogram is h_BAD .

I also noticed that when the file is opened 6Gb of memory are used, which is crazy!
How is it possible when the file is less that 200Mb?

I think I figured out what was the problem.
I had defined two TH1F histograms with 1e7 entries (1e7 x 4 bytes= 40 Mb) each in addition to the TH2F histograms which had 8e3 x 1e5 entries which took 8e8 x 4 bytes = 3.2 Gb each.

I reduced the entries of the TH1F histograms to 1e4 and the entries of the TH2F histograms to 8e3 x 1e3 and it seems that it’s working.

I guess that was the issue but when running this on a 64Gb machine it crashed again. Does it make any sense when there is enough memory and at the same time the histograms were stored in the heap memory by using new.

It could be that it is very compressed?

I am not sure about that because I am creating this root file and I don’t specify any compression factor.
But I don’t know if by default a big compression is done.

So the problem is indeed the size of individual histograms.
In the original, the size of one of the histogram (the on that happens to make it crash for me) is 1,200,224,004 (which already close to the maximum contain of the histogram (INT_MAX, i.e 2,147,483,647, but is okay-ish …),

During the streaming, this number is then multiply by 4 and assign to an int … which promptly overflows (so at this point, even if the operation ‘succeeded’ it would have lost data).

Then this cropped down value is used to allocate ‘enough’ memory to hold the data (to be compressed and then written to the disk).

However, the next operation is to do a loop using the original size to copy the data in … and of course this write way past the end of the (too small) buffer … leading to memory corruption.

I.e. we are missing a protection to prevent storing histogram that don’t fit within a single key.

Practically the limit of the number of bins, to be able to store it, in an histogram, is less than 536,870,911 bins (I did not calculate the exact number, this is INT_MAX/4) for floats and 268,435,455 bins for double.

Anyway, at those sizes, you may be better of storing the data in a TTree or a THnSparse rather than a regular histogram format (of course depending a lot of your use case and the occupancy of the histogram).

Thank you very much for your help!
Storing these data in a TTree is not an option because it’s a distribution. Reducing the binning is I believe the best in this case.

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