Segmentation fault Error. What is it?

Started by
56 comments, last by Tradone 18 years ago
So here's the summary in simpler terms. Error Type: Segmentation fault (core dumped) error. No runtime error: Total Cycles:10

			for(int i=0; i<=10; i++){
				skin.Read( "Body" );
			}		


Runtime error: Total Cycles:4

			std::map< std::string, std::map< std::string, std::string > >::iterator loop;
			for ( loop=mainData.GetData().begin(); loop != mainData.GetData().end(); loop++ ){

skin.Read( "Body" );
 
			}


No Runtime error: Total Cycles:1

			std::map< std::string, std::map< std::string, std::string > >::iterator loop;
			for ( loop=mainData.GetData().begin(); loop != mainData.GetData().end(); loop++ ){

skin.Read( "Body" );
 break;
			}



//inside method skin.Read( const std::string );
std::cout << para_skinTypeValue.substr(0, para_skinTypeValue.find("($") );
para_skinTypeValue=para_skinTypeValue.substr(para_skinTypeValue.find("($")+2, para_skinTypeValue.length()-para_skinTypeValue.find("($")-2 );
EvaluateFunction( para_skinTypeValue.substr(0, para_skinTypeValue.find(")") ) );
para_skinTypeValue=para_skinTypeValue.substr(para_skinTypeValue.find(")")+1, para_skinTypeValue.length()-para_skinTypeValue.find(")")-1 );



and it seems like the std::cout << para_skinTypeValue.substr(0, para_skinTypeValue.find("($") ); code is fine. But the second line para_skinTypeValue=para_skinTypeValue.substr(para_skinTypeValue.find("($")+2, para_skinTypeValue.length()-para_skinTypeValue.find("($")-2 ); causes the segmentation fault error when run twice inside the iterator. but doesn't create an error when run on a regular for loop. [Edited by - Tradone on April 3, 2006 10:19:30 PM]
Advertisement
Post the errors you're getting, please. Thanks!
Do you modify mainData or its contents in any way from within skin.Read()? If so, you are likely invalidating an iterator.

Stephen M. Webb
Professional Free Software Developer

I note that you're not doing anything with the iterator beside incrementing it, so what's the point?
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
The reason the last is "fine" is beause of that 'break;' statement - you're never excuting the body of that loop more than once.
They're runtime errors.
I get no errors.
none.
nada.
no seriously, this is driving me insane.

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@dummy-host.example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

this is all I get,
nothing recorded on the apache log.
no *.core file.
because it's run on the web.

the only one thing that I can do to view error messages are to execute the file directly from the console. but when I do that I get an error message as the following:

151# ./webtest.cgi
Content-type: text/html

<html>
<head>
<title>success</title>
</head>
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
Abort (core dumped)

So, all in all I can't even run the thing on the console.
but there is no error when run on the web though.
Quote:Original post by RDragon1
The reason the last is "fine" is beause of that 'break;' statement - you're never excuting the body of that loop more than once.


I put a break; there to test if the errors will persist even when the Read is performed only once.

well, the first thing I should do is make the program run on the console b/c I don't know what's causing the problem. It took me about an hour to trace it back to my first post.

and while I'm doing that I'll double check if skin.Read() makes changes to mainData along the way.


okay, I got it to run on the console.
that wasn't so hard, :D
Got rid of the
terminate called after throwing an instance of 'std::logic_error'  what():  basic_string::_S_construct NULL not validAbort (core dumped)

Errors.
If you're interested check out this link.
http://www.gamedev.net/community/forums/topic.asp?topic_id=385125

and since my program runs on the web, parameters must be fed, so in order to run it on the console I had to use command link arguements
http://www.site.uottawa.ca/~lucia/courses/2131-05/labs/Lab3/CommandLineArguments.html

and so I finally got it to work, and the error messages are
Segmentation fault (core dumped)


and if any of you developers know any debugging methods, or have any debugging tools. Thanks. ( I wonder if the VS Express debugging tools actually work )
How many elements are in the map when you run the second example?
Plus, try experimenting with a std::map without another map inside of it, just for testing purposes (in another project, of course). See if you get the same kind of error when running it in a simpler mode.
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire
Quote:Original post by deadimp
How many elements are in the map when you run the second example?
Plus, try experimenting with a std::map without another map inside of it, just for testing purposes (in another project, of course). See if you get the same kind of error when running it in a simpler mode.


there are dynamic amount of elements.
but generally 12 elements.

okay, i'll run the tests.

This topic is closed to new replies.

Advertisement