Thread: stack around the variable corrupted

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    78

    Arrow stack around the variable corrupted

    hi everyone,

    i am getting this runtime check error,

    stack around the variable"line_coords;" is corrupted,

    can anyone help me.

    Code:
    void defGeometry::populateGeometry(int nthPoint1, int nthPoint2)
    {		///////////////////////////////////////////////
    		//Initializing variables                     //
    		//Points that control the split of splines  ///
    		///////////////////////////////////////////////
    		nthN1Point = nthPoint1;
    		nthN2Point = nthPoint2;
    	////////////////////////////////////////////////////////////////
    	//To determine whether or not its Wicket gate or runner blade //
    	//If weicket gate then openEnd is ture otherwise if			  //	
    	//runner blade it is false.                                   //
    	////////////////////////////////////////////////////////////////
    		
    	bool openEnd = true;	
    	for(int i=0;i<ActionSide.NumberOfSections;i++)
    	{
    		tag_t	Spline1_tag=NULL_TAG,
    				Spline2_tag=NULL_TAG,
    				Spline3_tag=NULL_TAG,
    				Spline4_tag=NULL_TAG,
    				line;
    
    		struct Section Spline1,
    					   Spline2,
    					   Spline3,
    					   Spline4;
    
    		UF_CURVE_line_t line_coords;
    		geometricSection tempGeomSect;
    
    		double tangentPoints[4][3];
    
    		////////////////////////////////////////////////////////////
    		//We have created spline2 & spline3 first to get vectors  //
    		//at start & end point of splines to maintain tangency    //
    		//between consuective splines							  //
    		////////////////////////////////////////////////////////////
    
    		Spline2 = SectionXtractPoints(ActionSide.Sections[i]);
    		Spline2_tag = createSplineThruPoints(Spline2);
    		
    		tempGeomSect.section_tags[2]=Spline2_tag;
    
    		Spline3 = SectionXtractPoints(ReactionSide.Sections[i]);
    		Spline3_tag = createSplineThruPoints(Spline3);
    
    		tempGeomSect.section_tags[3]=Spline3_tag;
    		////////////////////////////////////////////////////////////////////////
    		//call for collecting vectors at start& end point of spline2 & spline3// 
    		////////////////////////////////////////////////////////////////////////
    		makeTangentPoints(tempGeomSect,tangentPoints);
    
    		////////////////////////////////////////////////////////
    		//CREATE THE NOZE SPLINES 1 AND 4					  //	
    		////////////////////////////////////////////////////////
    		//Only to create the Spline4                          //
    		//We have to reverse the vectors                      //
    		//For that we will use two temp vectors of section type/
    		////////////////////////////////////////////////////////
    
    		Spline1 = formSection(ActionSide.Sections[i],ReactionSide.Sections[i],nthN1Point);
    		Spline1_tag = createSplineThruPoints(Spline1,tangentPoints[0],tangentPoints[2]);
    
    		tempGeomSect.section_tags[1]=Spline1_tag;
    
    		//////////////////////////////////////////////////////////////////////////////
    		//If runner blade then we have to do the splie for tail end as well.		//
    		//Other wise if Wicket Gate we need to create a line rather than splitting. //
    		//////////////////////////////////////////////////////////////////////////////
    		
    		if(openEnd == false)
    		{
    			Section RevActSection = ActionSide.Sections[i];
    			Section RevReActSection = ReactionSide.Sections[i];
    		
    			vector<point> tmppts1(RevActSection.Points.rbegin(),RevActSection.Points.rend());
    			vector<point> tmppts2(RevReActSection.Points.rbegin(),RevReActSection.Points.rend());
    
    			RevActSection.Points = tmppts1;
    			RevReActSection.Points = tmppts2;
    
    			Spline4 = formSection(RevActSection,RevReActSection,nthN2Point);
    			Spline4_tag = createSplineThruPoints(Spline4,tangentPoints[1],tangentPoints[3]);
    		}
    		else
    		{
    			line_coords.start_point[3]=Spline2.Points[NumberOfPoints-nthN2Point-nthN1Point+1].pt[3];
    			line_coords.end_point[3]  =Spline3.Points[NumberOfPoints-nthN2Point-nthN1Point+1].pt[3];
    
    			UF_CURVE_create_line (&line_coords,& line );	
    		}
    		tempGeomSect.section_tags[4]=Spline4_tag;
    
    		UF_CALL(UF_OBJ_set_name(Spline1_tag,"spline11"));
    		UF_CALL(UF_OBJ_set_name(Spline2_tag,"spline22"));
    		UF_CALL(UF_OBJ_set_name(Spline3_tag,"spline33"));
    		UF_CALL(UF_OBJ_set_name(Spline4_tag,"spline44"));
    
    		sections.push_back(tempGeomSect);	
    	}
    }
    Section defGeometry::formSection( struct Section Section1,struct Section Section2,int nthPoint)
    {
    	int j;
    	struct Section defGeomSecTemp;
    	
    	for(j=(nthPoint-1);j>=0;j--)
    	{
    		defGeomSecTemp.Points.push_back(Section1.Points[j]);		
    	}
    	
    	for(j=1;j<nthPoint;j++)
    	{
    		defGeomSecTemp.Points.push_back(Section2.Points[j]);	
    	}
    	
    	defGeomSecTemp.NumberOfPoints = defGeomSecTemp.Points.size();
    	defGeomSecTemp.NumberOfPoints = nthN1Point+nthN2Point-1;	
    
    	return  defGeomSecTemp;
    }
    Section defGeometry::SectionXtractPoints(struct Section Section1)
    {
    	int j;
    	struct Section defGeomSecTemp;
    	for(j=(nthN1Point-1);j<(NumberOfPoints-nthN2Point+1);j++)
    	{
    	  defGeomSecTemp.Points.push_back(Section1.Points[j]);	  
    	}
    	defGeomSecTemp.NumberOfPoints=NumberOfPoints-(nthN1Point+nthN2Point-2);
    
    	return defGeomSecTemp;
    }
    tag_t defGeometry::createSplineThruPoints(struct Section thruSplineData)
    {
    	int	degree=3,
    		periodicity=0,
    		save_def_data = 0;
    	
    	double *p_par=NULL;
    	
    	tag_t thruSplineTag=NULL_TAG, ReplacedSpline=NULL_TAG;
    	
    	UF_CURVE_pt_slope_crvatr_t point_data[1000];
    	
    	for(int i=0; i<thruSplineData.NumberOfPoints; i++)
    	{
    		UF_VEC3_copy(thruSplineData.Points[i].pt,point_data[i].point);
    		point_data[i].slope_type = UF_CURVE_SLOPE_AUTO;
    		point_data[i].crvatr_type = UF_CURVE_CRVATR_NONE;
    	}
    	UF_CALL(UF_CURVE_create_spline_thru_pts(degree, periodicity,thruSplineData.NumberOfPoints,
    											point_data,p_par,save_def_data,&thruSplineTag));
    	
    	if(!thruSplineTag)
    	{
    		sysLogPrint("Failed to create spline %s", thruSplineData.Name);
    		return NULL_TAG;
    	}	
    	return thruSplineTag;
    }

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    tempGeomSect.section_tags[4]=Spline4_tag;
    Are you sure section_tags is 5 elements long?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    This error is typically called when you write to data that you don't own. For example, writing beyond the size of an array.
    So check what CornedBee mentions to see if it isn't writing data out of bounds.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-22-2007, 11:42 PM
  2. Need Help with Stack
    By trongsi in forum C++ Programming
    Replies: 9
    Last Post: 05-23-2006, 04:14 PM
  3. Finished Stack
    By the pooper in forum C Programming
    Replies: 11
    Last Post: 02-02-2005, 10:52 AM
  4. Stacks
    By Cmuppet in forum C Programming
    Replies: 19
    Last Post: 10-13-2004, 02:32 PM
  5. stack implementation problem-help needed
    By sanju in forum C Programming
    Replies: 1
    Last Post: 12-10-2002, 07:29 AM