×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    64

    A "main KERN-EXEC 3" error

    hi all,
    When I try to run my programme, it gives this error
    "Main KERN-EXEC 3". I think this error is caused by this sect of code:

    struct svm_model* model;
    char *modelPath = "E:/SVM1/file3.model";
    if((model=svm_load_model(modelPath))==0)
    {
    ......
    }

    in another file which defines the svm_load_model function,
    svm_model *svm_load_model(const char *model_file_name)
    {
    FILE *fp = fopen(model_file_name,"rb");
    if(fp==NULL) return NULL;
    svm_model *model = Malloc(svm_model,1);
    ........
    return model;
    }

    where svm_model is a kind of structure, also defined in the second file
    struct svm_model
    {
    ...............
    }
    Everything runs well on VS2008, however, when I try to run on N97, it gives error
    Can anyone give me some light? Thanks in advance.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,175

    Re: A "main KERN-EXEC 3" error

    "KERN-EXEC 3" is memory violation error, so you would be needing to do some debugging there to see which line would cause it, and then see which kind of pointer's are used in that line and then see why the offending pinter would be invalid.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: A "main KERN-EXEC 3" error

    Symbian does not like those /-s, use \\-s instead.

  4. #4
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    64

    Re: A "main KERN-EXEC 3" error

    hi symbiananyucca,
    After debugging on simulator, I fond the problem is here, caused by this statement,
    Code:
    char *endptr = NULL;
    svm_node *x_space = NULL;
    		while(1)
    		{
    			idx = strtok(NULL, ":");
    			val = strtok(NULL, " \t");
    			if(val == NULL)
    				break;
    			printf("value of idx %d \n",*idx);
    			x_space[j].index = (int) strtol(idx,&endptr,10);
    			x_space[j].value = strtod(val,&endptr);
    			++j;
    		}
    x_space[j].index = (int) strtol(idx,&endptr,10);
    where in the other part of this code, this is function which read a file line by line, the data in this line is like this:
    0 0 0 0 0 8 1:0.54572 2:0.66624 3:0.057015 5:0.55364 6:0.52775 7:1.2571e-005 8:0.51067 9:1.4186e-005 10:0.54231 11:0.66543 12:0.045493 14:0.56385 15:0.25462 17:0.52953 19:0.54572 20:0.6679 21:0.057404 23:0.55364 24:0.55867 25:7.0187e-005 26:0.51805 28:0.54511 29:0.66543 30:0.045493 32:0.56385 33:0.25462 35:0.52953

    where svm_node is a struct defined in the head file
    Code:
    struct svm_node
    {
    	int index;
    	double value;
    };
    Actually, after set breakpoint, I can see that the first value of *idx is 49, which is "integer 1" corresponding to ASCII. And the value of j is 0. I don't understand why one can not use
    x_space[j].index = (int) strtol(idx,&endptr,10);
    here.
    Can you give me some hints?

  5. #5
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    64

    Re: A "main KERN-EXEC 3" error

    thanks, wizard_hu. It's not the problem of path, after debugging, more precisely, I find the problem is caused by
    x_space[j].index = (int) strtol(idx,&endptr,10);
    I explained in detail in my last post, could you have a look? thanks

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: A "main KERN-EXEC 3" error

    What do you expect exactly from "strtok(NULL, ":");"?

  7. #7
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    64

    Re: A "main KERN-EXEC 3" error

    in fact, this method is used before
    Code:
    static char* readline(FILE *input)
    {
    	int len;
    
    	if(fgets(line,max_line_len,input) == NULL)
    		return NULL;
    
    	while(strrchr(line,'\n') == NULL)
    	{
    		max_line_len *= 2;
    		line = (char *) realloc(line,max_line_len);
    		len = (int) strlen(line);
    		if(fgets(line+len,max_line_len-len,input) == NULL)
    			break;
    	}
    	return line;
    }
    after this,
    Code:
    	max_line_len = 1024;
    	line = Malloc(char,max_line_len);
    	char *p = NULL;
    	char *endptr = NULL;
    	char *idx = NULL;
    	char *val = NULL;
    
          while(readline(fp)!=NULL)
    	{
    		p = strtok(line,":");   // this is the first time we use stroke to divide a string
                    int j = 0;
           		while(1)
    		{
    			idx = strtok(NULL, ":");
    			val = strtok(NULL, " \t");
    			if(val == NULL)
    				break;
    			x_space[j].index = (int) strtol(idx,NULL,10);
    			printf("open in model 13!\n");
    			x_space[j].value = strtod(val,&endptr);
    			++j;
    		}
           }
    It seems strange beacuse when I debug, i put the pointer on the parameter "10" in
    x_space[j].index = (int) strtol(idx,NULL,10);
    it gives error message:
    could not read from memory 0X00000A.
    however, the definition of strol is
    Code:
    IMPORT_C long	strtol	(const char *_n, char **_end_PTR, int _base);
    the third parameter is an integer.....

    And the compilor gives this error message:
    No source available for "( ntdll.dll )() "

    I read from internet, it seems we need to figure something when compile, however, this process is not clearly descripted.

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: A "main KERN-EXEC 3" error

    If you input is really "0 0 0 0 0 8 1:0.54572 2:0.66624 3:0.05...", I can not imagine how you get that '1' at *idx. The decision of using strtol on 0.66624 is also strange. Is x_space really a NULL pointer?

  9. #9
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    64

    Re: A "main KERN-EXEC 3" error

    sure, because this sect of code

    char *idx = NULL;
    idx = strtok(NULL, ":");
    look for the number before symbole before " : ", and the first one is "1" (which is a ASCII character in this function).
    And strtol is not used on value, it is used on index, that is 1,2,3....
    x_space is a NULL pointer, because we define
    svm_node *x_space = NULL;

  10. #10
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    64

    Re: A "main KERN-EXEC 3" error

    to add:
    before the function of
    Code:
    char *idx = NULL;
    idx = strtok(NULL, ":");
    there is a function to make strtok starts with "1:0.54572 2:0.66624 3:0.05..." and ignore the part " "0 0 0 0 0 8"

  11. #11
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: A "main KERN-EXEC 3" error

    I love your explanations. Using NULL pointers as arrays is already a brilliant idea in itself, and referring code pieces which have no trace in the post is also nice (there is a function to make strtok starts with "1:0.54572 2:0.66624 3:0.05..." and ignore the part " "0 0 0 0 0 8")

  12. #12
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    64

    Re: A "main KERN-EXEC 3" error

    hi, here is all of the code related to this error:

    Code:
    #define Malloc(type,n) (type *)malloc((n)*sizeof(type)); 
     svm_model *svm_load_model(const char *model_file_name)
    {
    	FILE *fp = fopen(model_file_name,"rb");
    	if(fp==NULL) return NULL;
    	
    	// read parameters
    	svm_model *model = Malloc(svm_model,1);
    	svm_parameter& param = model->param;
    	model->rho = NULL;
    	model->probA = NULL;
    	model->probB = NULL;
    	model->label = NULL;
    	model->nSV = NULL;
    
    	int elements = 0;
    	long pos = ftell(fp);
    
    	max_line_len = 1024;
    	line = Malloc(char,max_line_len);
    	char *p = NULL;
    	char *endptr = NULL;
    	char *idx = NULL;
    	char *val = NULL;
    	while(readline(fp)!=NULL)
    	{
    		p = strtok(line,":");
    		while(1)
    		{
    			p = strtok(NULL,":");
    			if(p == NULL)
    				break;
    			++elements;
    		}
    	}
    	elements += model->l;
    
    	fseek(fp,pos,SEEK_SET);
    	int m = model->nr_class - 1;
    	int l = model->l;
    	model->sv_coef = Malloc(double *,m);
    	int i;
    	for(i=0;i<m;i++)
    		model->sv_coef[i] = Malloc(double,l);
    	model->SV = Malloc(svm_node*,l);
    	
    	svm_node *x_space = NULL;
    	x_space = Malloc(svm_node,elements);   
    // the value of elements is the number of "digital pair, like '1:0.39911', usually it's more than 10000 "
    	if (x_space == NULL)
    		printf("not enough memory");
    	int j=0;
    	for(i=0;i<l;i++)
    	{
    		readline(fp);
    		model->SV[i] = &x_space[j];
    		p = strtok(line, " \t");
    		model->sv_coef[0][i] = strtod(p,&endptr);
    //following for loop delete the file head like "0 0 0 0 0 8"
    		for(int k=1;k<m;k++)
    		{
    			p = strtok(NULL, " \t");
    			model->sv_coef[k][i] = strtod(p,&endptr);
    		}
    		while(1)
    		{
    			idx = strtok(NULL, ":");
    			val = strtok(NULL, " \t");
    			if(val == NULL)
    				break;
    // here error occurs, gives the error "No source available for "(ntdll.dll )()"
    			x_space[j].index = (int) strtol(idx,NULL,10); 
    			x_space[j].value = strtod(val,&endptr);
    			++j;
    		}
    		x_space[j++].index = -1;
    	}
    	free(line);
    	
    	if (ferror(fp) != 0 || fclose(fp) != 0)
    		return NULL;
    
    	model->free_sv = 1;
    	return model;
    }
    hope this gives you more information]

  13. #13
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    64

    Re: A "main KERN-EXEC 3" error

    I think the problem is how to add this dll to my project. What do you think? some one gives this solution
    by entering Run_>Debug Configurations, and open "Executables" tab, choose then "Execitables built by this project".

    this does not work for me

    And I search from my computer, I found no ntdll.dll in the folder of “\S60\devices\Nokia_N97_SDK_v1.0\”, instead there is one names: imgpprintdll.dll under "\epoc32\release\winscw\udeb", so I add
    SYSTEMINCLUDE \epoc32\release\winscw\udeb
    in the mmp file, compile, it does not work....
    Last edited by azureskyi16; 2010-07-16 at 18:14.

  14. #14
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: A "main KERN-EXEC 3" error

    ntdll.dll is part of Windows, you can find it in the system32 folder.

  15. #15
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    64

    Re: A "main KERN-EXEC 3" error

    yes, I know that, the problem is how to use this programme in Nokia phone? The phone does not have this ntdll.dll.
    Now the programme runs well under windows, however, I want to use it on the phone. Do you have any ideas?

Similar Threads

  1. Kern-EXEC 0 panic after "iTransaction.SubmitL();"
    By nital_shah in forum Symbian
    Replies: 3
    Last Post: 2009-05-08, 13:01
  2. Replies: 0
    Last Post: 2007-09-27, 05:05
  3. error "mce KERN-EXEC 3", help
    By dt10000 in forum Symbian
    Replies: 6
    Last Post: 2003-06-25, 07:13
  4. Nokia 7650 "KERN EXEC 4" error
    By anindyachowdhury in forum Symbian
    Replies: 1
    Last Post: 2002-11-15, 11:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×