general fault exception

This is a discussion on general fault exception within the C++ Programming forums, part of the General Programming Boards category; hi, i have one dll in which i have written following function. I am calling this DLL from some othere ...

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

    general fault exception

    hi, i have one dll in which i have written following function. I am calling this DLL from some othere code. tool runs fine but while updating , it gives error as general fault exception. Can anyone please tell me what is the problem?



    Code:
    extern DllExport int GetStationCurveData( UF_KF_value_t *in, int num, UF_KF_value_t *out )
    {
    	void getvalue( SPOT spot, char *spot_str, char *instance, float *val );
    
    	char	*GDSVolumeName = NULL;	
    	char	*regionName = NULL;
    	char	*geomName = NULL;
    	char	 geomLocation[ GDS_LOCATION_SIZE ] = "";
    	char     msg[256]="";
    	
        float STAN_val[256];
    	
    
    	int	retVal = 0;
    	int i,x;
    	int n=0;
    	int	maxNbr = 0;
    	int no=0;
    	int	maxNbr_R = 0;
    	int	maxNbr_Z= 0;
    	//int	nbr = 0;
    	int arraysize;
    	int	numPoints = 0;
    	//int	mode = -1;
    	int numPoints_R =0;
    	int numPoints_Z =0;	
    
    
    
       ////////////////////////////////////////////////////////////////////////////////////////////////////
       //          strcture for storing "R" & "Z" values for corrusponding stations                      //
       //                                                              :Rajesh Gavali					 //
       ////////////////////////////////////////////////////////////////////////////////////////////////////
    
    	struct StaData
    	{
    		float RVAL[256];
    		float ZVAL[256];
    	};
    	
    	struct StaData ST1[256];
    	
    	SPOT	iSPOT = NULL;
    
    	/////////////////////////////////////////////////////
    	//	KF DATA										   //
    	/////////////////////////////////////////////////////
    
    	UF_KF_value_p_t  ST_kf_value;
    	UF_KF_value_p_t  R_kf_value;
    	UF_KF_value_p_t  Z_kf_value;
    	UF_KF_value_p_t  nos_kf_value;
    	UF_KF_value_p_t  noZ_kf_value;	
    
    
    	UF_KF_value_p_t  Station_List_value;
    	UF_KF_value_p_t	point = NULL;
    	UF_KF_value_p_t	listValue = NULL;
    
    	UF_KF_list_p_t list = NULL;
    
    
    	UF_KF_list_p_t Station_Name_list = NULL;
    	UF_KF_list_p_t R_Val_list = NULL;	
    	UF_KF_list_p_t Z_Val_list = NULL;	
    //////////////////////////////////////////////////////////
    	if(num==1)
    	{
    		PrintToInfoWindow( "\nInputs are correct!\n");	
    	}
    	else 
    	{
    		PrintToInfoWindow( "\nInputs are incorrect!\n");
    	}
    	
    	retVal = UF_initialize();
    
    	if( retVal )
    	{
    		PrintToInfoWindow("Failed\n");
    		sprintf( infoMsg, "UF_initialize() failed\n" );
    		ReturnBadList( out );
    		return -1;
    	}	
    	
    	UF_KF_ask_string( in[0], &GDSVolumeName );	
    	
    	retVal = OpenGDS( GDSVolumeName );
    
    	if( retVal )
    	{
    		PrintToInfoWindow("Failed\n");
    		sprintf( infoMsg, "to open GDS Volume\n" );
    		ReturnBadList( out );
    		UF_terminate();
    		return -1;
    	}
    	if( GDSSpot == NULL )
    	{
    		PrintToInfoWindow("Failed\n");
    		sprintf( infoMsg, "SPOT is not set to GDS Volume\n" );
    		PrintToInfoWindow( infoMsg );
    		ReturnBadList( out );
    		UF_terminate();
    		return -1;
    	}
    	iSPOT = GDSSpot;	
    
    	sprintf( geomLocation, "Cafmix.Cafd.Rec1" );
    
        retVal = idsspot_set( &iSPOT, geomLocation, strlen( geomLocation ) );
    
    	if(retVal)
    	{
    		PrintToInfoWindow("cant set spot to Cafmix.Cafd.Rec1");
    	}
    
    	numPoints = ids_getnbr( &iSPOT, "STAN", strlen("STAN "));
    
    	if( numPoints <= 0 )
    	{
    		PrintToInfoWindow("Failed\n");
    		PrintToInfoWindow("Failed to get No. of Control points\n");
    		ReturnBadList( out );
    		UF_terminate();
    		return -1;
    	}
    	
    	maxNbr = numPoints;	
    
       ////////////////////////////////////////////////////////////////////////////////////////////////////
       //          we are getting corresponding "STATION NUMBERS" from this function                     //
       //                                                               :Rajesh Gavali					 //
       ////////////////////////////////////////////////////////////////////////////////////////////////////
    
        x=ids_getreal(&iSPOT,"STAN",&nbr,STAN_val,&maxNbr,strlen("STAN" ));
    
        if(x)
    	{
    	  PrintToInfoWindow( "not getting array data" );
    	}
    	sprintf( infoMsg, "\nstation numbers are :\n");
    	PrintToInfoWindow( infoMsg );
    
    	for(arraysize=0;arraysize<maxNbr;arraysize++)
    	{
    		sprintf( infoMsg, " \n%d]%f\n",arraysize,STAN_val[arraysize]);
    		PrintToInfoWindow( infoMsg );
    	}
    
       ////////////////////////////////////////////////////////////////////////////////////////////////////
       //        From this loop we are getting corresponding "R" values for each station curves          //
       //                                                                         :Rajesh Gavali		 //
       ////////////////////////////////////////////////////////////////////////////////////////////////////
    
       sprintf(geomLocation,":Cafmix.Cafd.Sta<%f>",STAN_val[0]);
    
       retVal = idsspot_set( &iSPOT, geomLocation, strlen( geomLocation ) );
    
    	if(retVal)
    	{
    		PrintToInfoWindow("cant set spot to Cafmix.Cafd.Rec1");
    	}
    
       maxNbr_R  = ids_getnbr(&iSPOT, "R", strlen("R "));
    
    	if(  maxNbr_R <= 0 )
    	{
    		PrintToInfoWindow("Failed\n");
    		PrintToInfoWindow("Failed to get No. of Control points\n");
    		ReturnBadList( out );
    		UF_terminate();
    		return -1;
    	}else
    	{
    		sprintf(geomLocation,"\nNO. OF R VALUES=%d\n",maxNbr_R);
    		PrintToInfoWindow(geomLocation);	
    	}
    
        sprintf( infoMsg, "\nR values  are :\n");
    	PrintToInfoWindow( infoMsg );
    
    	for(arraysize=0;arraysize<maxNbr;arraysize++)
    	{
    	   sprintf(geomLocation,":Cafmix.Cafd.Sta<%f>.R",STAN_val[arraysize]);
    	   PrintToInfoWindow(geomLocation);	   
    	   
    	   retVal = ids_getreal(&iSPOT ,geomLocation,&nbr,ST1[arraysize].RVAL,&maxNbr_R,strlen( geomLocation ));
    	   
    	   for( i=0;i< maxNbr_R;i++)
    	   {
    		   sprintf( infoMsg, "\n%d]%f\n",i,ST1[arraysize].RVAL[i]);
    		   PrintToInfoWindow( infoMsg );
    	   }
       }   
       ////////////////////////////////////////////////////////////////////////////////////////////////////
       //        From this loop we are getting corresponding "Z" values for each station curves          //
       //                                                                         :Rajesh Gavali		 //
       ////////////////////////////////////////////////////////////////////////////////////////////////////
    
       sprintf(geomLocation,":Cafmix.Cafd.Sta<%f>",STAN_val[0]);
    
       retVal = idsspot_set( &iSPOT, geomLocation, strlen( geomLocation ) );
    
       if(retVal)
    	{
    		PrintToInfoWindow("cant set spot to Cafmix.Cafd.Rec1");
    	}
    	
    	maxNbr_Z  = ids_getnbr(&iSPOT, "Z", strlen("Z"));
    
    	if(  maxNbr_Z <= 0 )
    	{
    		PrintToInfoWindow("Failed\n");
    		PrintToInfoWindow("Failed to get No. of Control points\n");
    		ReturnBadList( out );
    		UF_terminate();
    		return -1;
    	}else
    	{
    		sprintf(geomLocation,"\nNO. OF Z VALUES=%d\n",maxNbr_Z);
    		PrintToInfoWindow(geomLocation);	
    	}
    
        sprintf( infoMsg, "\nZ values  are :\n");
    	PrintToInfoWindow( infoMsg );
    
        for(arraysize=0;arraysize<maxNbr;arraysize++)
       {
    	   sprintf(geomLocation,":Cafmix.Cafd.Sta<%f>.Z",STAN_val[arraysize]);
    	   PrintToInfoWindow(geomLocation);
    
    	   
    	   retVal = ids_getreal(&iSPOT ,geomLocation,&nbr,ST1[arraysize].ZVAL,&maxNbr_Z,strlen( geomLocation ));
    	   
    	   for( i=0;i<maxNbr_Z ;i++)
    	   {
    		   sprintf( infoMsg, "\n%d]%f\n",i,ST1[arraysize].ZVAL[i]);
    		   PrintToInfoWindow( infoMsg );
    	   }
       }
       for(arraysize=0;arraysize<maxNbr;arraysize++)
    	{		
    	   UF_KF_make_number (STAN_val[arraysize],&ST_kf_value );
    	   UF_KF_list_push(list ,ST_kf_value, &list );
    	}	
    	for(arraysize=0;arraysize<maxNbr;arraysize++)
    	{
    		for( i=0;i<maxNbr_R ;i++)
    		{
    			UF_KF_make_number (ST1[arraysize].RVAL[i],& R_kf_value);
    			UF_KF_list_push( list  , R_kf_value, &list );
    		}
    		for( i=0;i<maxNbr_Z;i++)
    		{
    			UF_KF_make_number (ST1[arraysize].ZVAL[i],& Z_kf_value);
    			UF_KF_list_push(list,Z_kf_value,&list);
    		}
    	} 
    	UF_KF_make_number (maxNbr,& nos_kf_value); 
    	UF_KF_list_push(list, nos_kf_value,&list);
        UF_KF_make_number (maxNbr_Z,&noZ_kf_value);
    	UF_KF_list_push(list,noZ_kf_value,&list);
    
        UF_KF_make_list(list,out); 
    
    CloseGDS();
    
    //free();
    return 0;
    }

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,246
    Quote Originally Posted by chintugavali View Post
    hi, i have one dll in which i have written following function. I am calling this DLL from some othere code. tool runs fine but while updating , it gives error as general fault exception. Can anyone please tell me what is the problem?
    What LINE is causing the error? A debugger will tell you this information.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    78
    problem is i cant debug because i am calling it from one tool, & only place i can check is in the tool ouptitself

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,246
    Quote Originally Posted by chintugavali View Post
    problem is i cant debug because i am calling it from one tool, & only place i can check is in the tool ouptitself
    Try adding print statements to see generally what area is crashing -- once you know the general area, add more detailed print statements in that area to narrow it down further, etc.

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    78
    i am getting error while run time.... how can i debug any error from printf in this case?

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,246
    Quote Originally Posted by chintugavali View Post
    i am getting error while run time.... how can i debug any error from printf in this case?
    If you have something like this:

    Code:
    printf("1\n");
    a();
    printf("2\n");
    b();
    printf("3\n");
    c();
    printf("4\n");
    d();
    And you run the program and see:

    Code:
    1
    2
    3
    <crash>
    Then obviously it crashed somewhere between printf("3\n") and printf("4\n"), right?

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by chintugavali View Post
    i am getting error while run time.... how can i debug any error from printf in this case?
    it's a method called "printlining". Say we have this code:
    Code:
    int main()
    {
       int x = 0; 
       int y = 3;
       int z;
    
    ... bunch of other code ... 
    
       z = x / y;
       return 0;
    We can then debug the "division by zero error" by adding printfs to the code:
    Code:
    int main()
    {
       int x = 0; 
       int y = 3;
       int z;
    
        printf("At point A\n"); 
    
    ... bunch of other code ... 
        printf("At point K\n"); 
        
       z = x / y;
        printf("At point L\n"); 
    
       return 0;
    You will then see output:
    Code:
    At point A
    ...
    At point K
    Division by zero error...
    So you know that the problem is between K and L.

    If you have no console to print to, you can write to a text-file. As long as it's something that doesn't disappear when your application crashes.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    The time spent debugging would be better spent rewriting with std::string, std::vector, and std:stringstream instead of char *, arrays, and sprintf. I think 99&#37; of C++'s bad reputation comes from people using it like C.
    Last edited by medievalelks; 04-26-2008 at 11:06 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Locating A Segmentation Fault
    By Stack Overflow in forum C Programming
    Replies: 12
    Last Post: 12-14-2004, 12:33 PM
  2. A general protection exception failure
    By louis_mine in forum C Programming
    Replies: 7
    Last Post: 11-25-2004, 01:22 AM
  3. General Protection Exception
    By s9uare in forum C++ Programming
    Replies: 1
    Last Post: 11-02-2002, 09:46 AM
  4. general protection exception
    By chiw in forum C Programming
    Replies: 1
    Last Post: 08-14-2002, 09:54 AM
  5. General protection exception??
    By jonesy in forum C Programming
    Replies: 6
    Last Post: 10-10-2001, 12:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21