I had a program which ran great interactively. Now I have compiled it so that I can run the program non interactively on the high performance processing center at my university.There are all kinds of issues, so I made this test code to pinpoint the problems and work through them. I have tried a few versions of this code.
Upon running ./test > LOG0 I get the following error.
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted
–LOG0–
acarnes@r14a-s31:testcode$ cat LOG0
starting test program
creating new Tstring
new TString created.
creating TFile with c_str in constructor
TFile with c_str in constructor has been created
creating TMVA::Factory
–test.cpp–
#include "TObject.h"
#include "TFile.h"
#include "TString.h"
#include "TMVA/Factory.h"
#include "TMVA/Tools.h"
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <string>
int main(int argc, char *argv[])
{
std::cout << "starting test program" << std::endl;
std::cout << "creating new Tstring" << std::endl;
TString filename("test.root");
std::cout << "new TString created." << std::endl;
std::cout << "creating TFile with c_str in constructor" << std::endl;
TFile* file = new TFile("blah.root", "RECREATE");
std::cout << "TFile with c_str in constructor has been created" << std::endl;
std::cout << "creating TMVA::Factory" << std::endl;
// Load TMVA Library
TMVA::Tools::Instance();
//TString weightname("weightname");
//TString options("!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification");
TMVA::Factory* factory = new TMVA::Factory("weightname", file,"!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification" );
//clean up
delete factory;
file->Close();
std::cout << "TMVA::Factory created";
return 0;
}
Then I tried to rewrite the code. Upon running version 2 below. I received the following error.
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x0000003578899fc5 in waitpid () from /lib64/libc.so.6
#1 0x000000357883c331 in do_system () from /lib64/libc.so.6
#2 0x00002ad4cb526a96 in TUnixSystem::StackTrace ()
from /apps/root/5.32.01/lib/libCore.so
#3 0x00002ad4cb52636c in TUnixSystem::DispatchSignals ()
from /apps/root/5.32.01/lib/libCore.so
#4 <signal handler called>
#5 0x0000000000402091 in main ()
===========================================================
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug 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 0x0000000000402091 in main ()
===========================================================
*** glibc detected *** ./test: double free or corruption (!prev): 0x0000000007019ce0 ***
======= Backtrace: =========
/lib64/libc.so.6[0x357887230f]
/lib64/libc.so.6(cfree+0x4b)[0x357887276b]
/apps/root/5.32.01/lib/libCore.so(_ZN8TStorage13ObjectDeallocEPv+0x68)[0x2ad4cb4890c8]
/apps/root/5.32.01/lib/libRIO.so(_ZN5TFileD0Ev+0x217)[0x2ad4cae5e2d7]
/apps/root/5.32.01/lib/libCore.so(_ZN11TCollection14GarbageCollectEP7TObject+0x84)[0x2ad4cb4cced4]
/apps/root/5.32.01/lib/libCore.so(_ZN5TList6DeleteEPKc+0x145)[0x2ad4cb4d31e5]
/apps/root/5.32.01/lib/libCore.so(_ZN5TROOTD1Ev+0xbf)[0x2ad4cb48270f]
/lib64/libc.so.6(__cxa_finalize+0x8e)[0x357883368e]
/apps/root/5.32.01/lib/libCore.so[0x2ad4cb432386]
Here is the output of the program.
–LOG0v2–
starting test program
creating new Tstring
new TString created.
creating TFile with c_str in constructor
TFile with c_str in constructor has been created
creating TMVA::Factory
–testv2.cpp–
#include "TObject.h"
#include "TFile.h"
#include "TString.h"
#include "TMVA/Factory.h"
#include "TMVA/Tools.h"
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <string>
int main(int argc, char *argv[])
{
std::cout << "starting test program" << std::endl;
std::cout << "creating new Tstring" << std::endl;
TString filename("test.root");
std::cout << "new TString created." << std::endl;
std::cout << "creating TFile with c_str in constructor" << std::endl;
TFile* file = new TFile("blah.root", "RECREATE");
std::cout << "TFile with c_str in constructor has been created" << std::endl;
std::cout << "creating TMVA::Factory" << std::endl;
// Load TMVA Library
TMVA::Tools::Instance();
TString weightname("weightname");
TString options("!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification");
TMVA::Factory* factory = new TMVA::Factory(weightname, file, options );
//clean up
delete factory;
file->Close();
std::cout << "TMVA::Factory created";
return 0;
}