segmentation violation????

Hello
I have a problem while executing my code. It gave no error while compiling. The error i get is:

*** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library "/lib/tls/libthread_db.so.1".
Attaching to program: /proc/29243/exe, process 29243
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
[New Thread -152082752 (LWP 29243)]
(no debugging symbols found)...done.
(no debugging symbols found)...done.

0x007c17a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x01b1c4b3 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2 0x01ac5779 in do_system () from /lib/tls/libc.so.6
#3 0x0087098d in system () from /lib/tls/libpthread.so.0
#4 0x00a6d4b7 in TUnixSystem::Exec () from /usr/local/root/lib/libCore.so.5.24
#5 0x00a7314f in TUnixSystem::StackTrace ()
from /usr/local/root/lib/libCore.so.5.24
#6 0x00a6fb4a in TUnixSystem::DispatchSignals ()
from /usr/local/root/lib/libCore.so.5.24
#7 0x00a6fbd8 in SigHandler () from /usr/local/root/lib/libCore.so.5.24
#8 0x00a6ee55 in sighandler () from /usr/local/root/lib/libCore.so.5.24
#9 <signal handler called>
#10 0x0807c947 in main ()



Can u tell me where is the problem?
Thanks in advance.
Not for certain, but I would start by considering that signal handlers should do very little (looking at frame 9).
Invoking system() from within a signal handler is a recipe for disaster.
Hoe can i get over this problem? I am not very expert at these things.
You haven't provided enough information to know for certain that that is the problem.

Have you also compiled with _REENTRANT and _THREAD_SAFE? eg,

g++ -D_REENTRANT -D_THREAD_SAFE file.cpp
my code is

#include "Pythia.h"
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TCanvas.h"
using namespace Pythia8;

int main() {

Pythia pythia;

Event& event = pythia.event;
ParticleDataTable& pdt = pythia.particleData;
Info& info = pythia.info;

pythia.readFile("ruchi.cmnd");
int nEvent = pythia.mode("Main:numberOfEvents");
int nList = pythia.mode("Main:numberToList");
int nShow = pythia.mode("Main:timesToShow");
bool showCS = pythia.flag("Main:showChangedSettings");
bool showCPD = pythia.flag("Main:showChangedParticleData");
double fractionqq;
double fractionqg;
double fractiongg;
int nListJets = 5;
double ebeam = 7000.0;

pythia.init();

if (showCS) pythia.settings.listChanged();
if (showCPD) pdt.listChanged();
TFile *file = TFile::Open("ruchi.root","recreate");

CellJet cellJet;

TH1F *nJets = new TH1F ("nJets","number of jets", 20, -0.5, 19.5);

TH2D *hfractiongg = new TH2D("fractiongg","Fraction of gg", 100, 0., 0.8, 100, 0., 1.);

TH2D *hfractionqq = new TH2D("fractionqq","Fraction of qq", 100, 0., 0.8, 100, 0., 1.);
TH2D *hfractionqg = new TH2D("fractionqg","Fraction of qg", 100, 0., 0.8, 100, 0., 1.);

pythia.readString("PhaseSpace:pTHatMin = 0");
pythia.readString("PhaseSpace:pTHatMax = 5600.");
Min = ptmin");
double qq=0;
double qg=0;
double gg=0;
double tot=0;

int nPace = max(1, nEvent / max(1, nShow) );
double xT1=0.0;
for (int i=0; i<100; i++){
double xT2=xT1+.01;


for (int iEvent = 0; iEvent < nEvent; ++iEvent) {
if (nShow > 0 && iEvent % nPace == 0)
cout << " Now begin event " << iEvent << endl;
if (!pythia.next()) {
cout << " Event generation aborted prematurely, owing to error!\n";
break;
}

if (iEvent < nList) {
info.list();
pythia.process.list();
event.list();
}

cellJet. analyze( pythia.event );

double et = cellJet.eT(0);
double xT = et/ebeam;
if (xT <= xT2 && xT >=xT1){


if (pythia.process[3].id() == 21 && pythia.process[4].id() == 21)
gg = gg+1;
else
if(pythia.process[3].id()>=1 && pythia.process[3].id()<=5 && pythia.process[4].id()>=1 && pythia.process[4].id()<=5)
qq =qq+1;
else
if(pythia.process[3].id()>=1 && pythia.process[3].id()<=5 && pythia.process[4].id()==21 || pythia.process[4].id()>=1 && pythia.process[4].id()<=5 && pythia.process[3].id()==21)
qg = qg+1;


tot = tot + qq + qg + gg;
fractionqq = qq/tot;
fractionqg = qg/tot;
fractiongg = gg/tot;

cout << "number of qq events = " << qq << endl << "number of qg events = " << qg << endl << "number of gg events = " << gg << endl << "number of total events = " << tot << endl;


cout << "fraction of qq events = " << fractionqq << endl << "fraction of qg events = " << fractionqg << endl << "fraction of gg events = " << fractiongg << endl;
double xTmean=(xT1+xT2)/2.;
hfractionqq->Fill(xTmean, fractionqq );
hfractionqg->Fill(xTmean, fractionqg );
hfractiongg->Fill(xTmean, fractiongg );
}

}
xT2=xT1;
}

file->Write();
file->Close();
delete file;
// Done.
return 0;
}


Ithonk the problem is with the line:

double xT = et/ebeam;
Ifound this by commenting various lines.

I compiled the code using

g++ -O2 -ansi -W -Wall -Wshadow -I../include ruchi.cc -o ruchi.exe -L../lib/archive -lpythia8 -llhapdfdummy `root-config --cflags --libs`


Is this information enough?
Ruchi, i am a beginner user of cplusplus.com.
i have registered myself....
plz plz plz let me knw the procedure to post a new query on the forums column..
Last edited on
First login to your account, then go to the forum in which you want to post your query.
Below all the topics there is a link where you can "post new topic".
For example this is the link for new post in beginners forum

http://www.cplusplus.com/forum/post.cgi?w=new&i=851
Segmentation fault occurs whenever your program tries to access INACCESSIBLE locations.
For example take this case::-
Every process has OSdata section at the top of its virtual address space and the process is not supposed to modify that section and any memory reference to that section in your program leads to error called SEGMENTATION FAULT while execution.

Also take this case:
You created linked list with nodes.
class node{
int element;
}
You created 1 node and deleted 1 node.Now there are no nodes in linked list.Now any attempt to access element of first node through linked list pointer results in SEGMENTATION FAULT as there is no first node and your program is trying to access Unallocated NODE.

See whether you have made any such kind of errors.
Topic archived. No new replies allowed.