LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2009, 04:48 AM   #1
gpfdez83
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: Disabled
Unhappy Error : glibc invalid pointer error


Hello!

I'm having problems executing my webapplication because this error.

Quote:
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] ======= Backtrace: =========, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] /lib/tls/i686/cmov/libc.so.6[0xb7cd13f4], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] /lib/tls/i686/cmov/libc.so.6(cfree+0x96)[0xb7cd3456], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb7eaf0b1], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] /opt/lampp/htdocs/proyecto/satDNA.cgi[0x8091a96], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] /opt/lampp/htdocs/proyecto/satDNA.cgi[0x804c833], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] /opt/lampp/htdocs/proyecto/satDNA.cgi[0x804e68f], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7c78685], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] /opt/lampp/htdocs/proyecto/satDNA.cgi[0x804b0e1], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] ======= Memory map: ========, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] 08048000-080b0000 r-xp 00000000 08:05 468704 /opt/lampp/htdocs/proyecto/satDNA.cgi, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] 080b0000-080b1000 r--p 00067000 08:05 468704 /opt/lampp/htdocs/proyecto/satDNA.cgi, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] 080b1000-080b2000 rw-p 00068000 08:05 468704 /opt/lampp/htdocs/proyecto/satDNA.cgi, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] 080b2000-080b5000 rw-p 080b2000 00:00 0 , referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] 08467000-084a9000 rw-p 08467000 00:00 0 [heap], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7b00000-b7b21000 rw-p b7b00000 00:00 0 , referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7b21000-b7c00000 ---p b7b21000 00:00 0 , referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7c61000-b7c62000 rw-p b7c61000 00:00 0 , referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7c62000-b7dba000 r-xp 00000000 08:05 251242 /lib/tls/i686/cmov/libc-2.8.90.so, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7dba000-b7dbc000 r--p 00158000 08:05 251242 /lib/tls/i686/cmov/libc-2.8.90.so, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7dbc000-b7dbd000 rw-p 0015a000 08:05 251242 /lib/tls/i686/cmov/libc-2.8.90.so, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7dbd000-b7dc0000 rw-p b7dbd000 00:00 0 , referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7dc0000-b7dcd000 r-xp 00000000 08:05 226252 /lib/libgcc_s.so.1, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7dcd000-b7dce000 r--p 0000c000 08:05 226252 /lib/libgcc_s.so.1, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7dce000-b7dcf000 rw-p 0000d000 08:05 226252 /lib/libgcc_s.so.1, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7dcf000-b7df3000 r-xp 00000000 08:05 251250 /lib/tls/i686/cmov/libm-2.8.90.so, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7df3000-b7df4000 r--p 00023000 08:05 251250 /lib/tls/i686/cmov/libm-2.8.90.so, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7df4000-b7df5000 rw-p 00024000 08:05 251250 /lib/tls/i686/cmov/libm-2.8.90.so, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7df5000-b7df6000 rw-p b7df5000 00:00 0 , referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7df6000-b7ed9000 r-xp 00000000 08:05 195117 /usr/lib/libstdc++.so.6.0.10, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7ed9000-b7edd000 r--p 000e3000 08:05 195117 /usr/lib/libstdc++.so.6.0.10, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7edd000-b7ede000 rw-p 000e7000 08:05 195117 /usr/lib/libstdc++.so.6.0.10, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7ede000-b7ee4000 rw-p b7ede000 00:00 0 , referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7ee4000-b7f08000 r-xp 00000000 08:05 196776 /usr/lib/libcgicc.so.5.0.2, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7f08000-b7f09000 r--p 00023000 08:05 196776 /usr/lib/libcgicc.so.5.0.2, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7f09000-b7f0a000 rw-p 00024000 08:05 196776 /usr/lib/libcgicc.so.5.0.2, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7f19000-b7f1c000 rw-p b7f19000 00:00 0 , referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7f1c000-b7f36000 r-xp 00000000 08:05 226259 /lib/ld-2.8.90.so, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7f36000-b7f37000 r-xp b7f36000 00:00 0 [vdso], referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7f37000-b7f38000 r--p 0001a000 08:05 226259 /lib/ld-2.8.90.so, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] b7f38000-b7f39000 rw-p 0001b000 08:05 226259 /lib/ld-2.8.90.so, referer: http://localhost/proyecto/FormatSelection.cgi
[Sat Oct 31 20:23:59 2009] [error] [client 127.0.0.1] bfc23000-bfc38000 rw-p bffeb000 00:00 0 [stack], referer: http://localhost/proyecto/FormatSelection.cgi

I call a function and when it returns a vector of int, it crash. The line where the execution stops is this, which we can found it in satDNA.cgi and calls a function of sample.cgi

typeOfPosition = theSample.classifyPositionsHTML(j,k, outFile);

If you need more details or the code, please tell me, I don't know what to do.

Thanks a lot.
 
Old 11-04-2009, 02:10 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
We need at least the code for the calling function and the function being called. Use [code] tags or else we won't read it.
 
Old 11-04-2009, 02:32 PM   #3
gpfdez83
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for your reply. I put the code down here:

Calling Function
Quote:
Code:
int Ejecutar (){

	/**
	*  Abrimos el fichero "datos.txt" en se han almacenado los datos de entrada de la 
	*  aplicación para realizar la ejecución. 
	*/

	ifstream datos;
	
	ofstream parFiles("/opt/lampp/tmp/parejas.txt");
	datos.open("/opt/lampp/tmp/datos.txt");

	//Modificamos los permisos para que podamos escribir las parejas analizadas en el fichero.
	string pr = "/opt/lampp/tmp/parejas.txt";
	if (chmod(pr.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IWOTH | S_IROTH | S_IXOTH) == -1) {
		perror("chmod");
	}  

	string line;
	getline(datos,line);
	string argv[6];
	int i=0;


	do{
		argv[i] = line;
		i++;
		getline(datos,line);

	}while(!line.empty() && !line.find_first_of("\n\t\r ")== 0 && i<6);


	datos.close();


	// En este caso nuestro número de argumentos será el total -1 ya que empezamos
	// la cuenta en 0. Los argumentos posibles serán : Tiempo de divergencia (opcional),
	// Exclude Polimorphic Positions/Otherwise y Pairwise/Complete Deletion. 


	if ((i != 6)) 
	{
		exit(1);
	}

	// LECTURA ---------------------------------------------------------



	char* fc = &argv[0][0];



	SEQFILE *insfp;
	if ((insfp = seqfopen(fc, "r", NULL)) == NULL) {
		cerr<<"There was an error opening "<<argv[0]<<". Aborting."<<endl;
		exit(1);
	}	

	int nf = atoi(argv[5].c_str());		
	string format = string(seqfformat(insfp, 0));

	sample theSample(insfp,nf);
	
	cerr << "** Read "<< format;
	cerr << " file with " << theSample.noSpecies() <<
	" species containing ";

	int pol, comD;

	if (atoi(argv[2].c_str())!=0)
	{
		pol = atoi(argv[3].c_str());
		comD = atoi(argv[4].c_str());
		theSample.set_lT((double)atof(argv[2].c_str()));
	}

	else if (atoi(argv[2].c_str()) == 0)
	{
		pol = atoi(argv[3].c_str());
		comD = atoi(argv[4].c_str());
		theSample.set_lT(-1);
	}


	if ((pol != 0) && (pol != 1) )
	{
		// help();
		exit(1);
	}

	if ((comD != 0) && (comD != 1) )
	{
		//help();
		exit(1);
	}




	int sequenceSize = theSample.lengthOfSequences();


	cerr << sequenceSize << " nucleotids each."<<endl;

	// CALCULAR RESÚMENES ----------------------------------------------
	/** SÓLO DOS ESPECIES, SP1 y SP2, de momento */

	/* vector< vector<int> > resumenSP1 = theSample[0].summarise();

	vector< vector<int> > resumenSP2 = theSample[1].summarise();*/

	//AMPLIAMOS A MÁS DE DOS ESPECIES, COMPARACIONES 2 a 2


	for(int i =0;i<nf;i++){
		vector< vector<int> > resumen = theSample[i].summarise();

	}

			
	// SALIDA ----------------------------------------------------------

	//SE CREAN X FICHEROS DE SALIDA (1 POR CADA COMPARACIÓN REALIZADA)
	int fout = 0;
	for(int x=nf-1;x>0;x--){ fout+=x;}
	

				
	int fmt=0;
	for(int j=0;j<nf;j++)
	{
		for(int k=j+1;k<nf;k++)
		{
			
			if(j!=k){
					std::stringstream out ;
					//out.flush();
					//out.clear();
					
					out<<"/opt/lampp/htdocs/proyecto/AnalisisPareja"<<fmt<<".html";
					
					string fil = out.str();
			
					ofstream outFile(fil.c_str());
				
										

					//ofstream outputFile("/opt/lampp/htdocs/proyecto/resultado.html");//argv[1].c_str());
					//outFiles[fmt].open(nomFiles[fmt].c_str());

					if (chmod(fil.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IWOTH | S_IROTH | S_IXOTH) == -1) {
						perror("chmod");
					}    
					

					if(!outFile) {
						cerr << "Cannot open " << outFile << " for input";
						exit(1);
					}

					// En esta llamada vamos a tener que incluir un bucle para poder comparar los distintos formatos entre sí
					// de modo que los indices que ahora son 0 y 1, pasarán a cambiar según los formatos que deseemos
					// comparar. Así también quedará modificado el fichero de salida, ya que se creará uno por comparación.

					parFiles<<theSample[j].speciesId()<<" - "<< theSample[k].speciesId()<<endl;
		
				
					cerr<<"PRE Classify SATDNA.CPP:"<<j<<" Y "<<k<<"   "<<endl;
					vector <int> typeOfPosition;
					typeOfPosition = theSample.classifyPositionsHTML(j,k, outFile);
					cout<<"ANTES DE LA LLAMADA"<<endl;
					//typeOfPosition = theSample.classifyPositionsHTML(j,k, outFile);
					cerr<<"PASA classify de "<<j<<" Y "<<k<<" "<<endl;

					//vector <int> typeOfPosition = theSample.classifyPositionsHTML(0,1, outputFile);

					if (comD == 0)
					{
						theSample.stats(pol, typeOfPosition,j,k);
						
						if (pol == 0)
							outFile << "Shared polymorphisms not excluded<br/>Pairwise option<br/>"<< endl;
						else
							outFile << "Shared polymorphisms excluded<br/>Pairwise option<br/>"<< endl;

						theSample.writeHTMLStats(typeOfPosition, outFile, pol,j,k);
						theSample.writeHTMLfooter(outFile);
					}
					else
					{
						sample comDSample =  theSample;
						comDSample.stats(pol, typeOfPosition,j,k);

						if (pol == 0)
							outFile << "Shared polymorphisms not excluded<br/>Complete deletion option<br/>"<< endl;
						else
						    outFile << "Shared polymorphisms excluded<br/>Complete deletion option<br/>"<< endl;

						comDSample.writeHTMLStats(typeOfPosition, outFile, pol,j,k);
						comDSample.writeHTMLfooter(outFile);

					}

					// Text file with the shared polymorphisms -----------------------

					//char* tmp2;
					string name, newname;
					string argv1(argv[0]);

					int pos = argv1.find_first_of('.', 1);

					if (pos == -1) { // no dot in filename (yeah, just in case)
						std::stringstream out;
						out << argv[0].c_str()<<"_noSP"<<fmt;
						newname = out.str();
					//	out.flush();
					//	out.clear();
					}
					else {
						string filename = argv1.substr(0, pos);
						string extension = argv1.substr(pos, argv1.length());
						std::stringstream out;
						out << filename<<"_noSP"<<fmt<<extension;
						newname = out.str();//filename + "_noSP" + s.c_str() + extension;
					}

					cerr<<"antes de crear objeto"<<endl;

					sample theSample_noPol(theSample, typeOfPosition);



					cerr<<"despues de crear objeto"<<endl;

					theSample_noPol.write(newname.c_str(), format,j,k);

					cerr << "** Output in files " << fil << " and " << newname.c_str() << endl;
					
					
					//outFile.flush();
					//outFile.close();

						
					//typeOfPosition.clear();
					//typeOfPosition.~vector();
					fmt++;

				
				}
				

			}	
		}	
//	}

	parFiles.close();
	
	return fout;


}
Function Being Called

Quote:
Code:
vector < int >
sample::classifyPositionsHTML(int indexA, int indexB, ostream & oFile)
{

    vector< int > typeOfPosition((*this).lengthOfSequences(), -1);
    // Stores the type of each position as defined in enum at util.h
	
    vector<float> percent((*this).lengthOfSequences(), 0.0);

    (*this)[indexA].classifyPositions((*this)[indexB].summarise(),
                                      typeOfPosition, percent);

	//percent.clear();


	(*this).writeHTMLheader(oFile);

	(*this).writeHTMLsummary(indexA, indexB, typeOfPosition, oFile);

	(*this).writeHTMLlegend(oFile);

    (*this).writeHTMLrichnessAT(indexA, indexB, oFile);

	

    (*this).writeHTMLconsensus(LINE_LENGTH_INTERLEAVED,
			       indexA, indexB, oFile);

    (*this).writeHTMLnucleotids(LINE_LENGTH_INTERLEAVED,
				indexA, indexB, typeOfPosition, oFile);

    (*this).writeHTMLlegend(oFile);

    (*this).writeHTMLpositions(LINE_LENGTH_INTERLEAVED,
				indexA, indexB, typeOfPosition, oFile);
	
	cerr<<"ANTES DEL RETURN DE CLASSIFY POSITIONS HTML DE SAMPLE.CPP: "<<indexA <<" Y " <<indexB<<" "<<endl;

	return typeOfPosition;

   

}
Thanks a lot for your help.
 
Old 11-04-2009, 02:48 PM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Please translate the comments into English and change the tabs to, say, three spaces. This is one of the reasons I never use tabs, spaces never go crazy.

Also cleanup the useless "(*iter)." dereferences. There are reasons why you would have to do that (local vars with the same name as members), but iter-> is preferable.

Is classifypositionsHTML really supposed to change the sample? It should be const if it's not supposed to.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
phusion passenger module generating invalid pointer error cozcol Linux - Newbie 0 04-14-2009 06:39 PM
Error during cimserver start : *** glibc detected *** realloc(): invalid pointer MaverickLikesMustang Linux - Software 0 02-14-2008 06:42 AM
glibc detected : Invalid Pointer Error DragonM15 Linux - Software 3 06-01-2007 12:43 AM
Marble Blast Demo (glibc invalid pointer error) KRiSX.cjb.net Linux - Games 1 05-24-2006 05:53 AM
Glibc free() invalid pointer pierre-luc Programming 3 11-13-2005 08:04 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration