getting "mi_cmd_var_create: unable to create variable object" error msg

Hi,
i am working in C in Fedora Eclipse 3.3.0 with gdb debugger. I am geting segmentation fault with an error message "mi_cmd_var_create: unable to create variable object" on debugging the program.

What should I do to solve this problem?

rgds,
Dona_m

Is this variable local to a function or is it global. If global check the allocated data segment size else check the allocated stack segment. Try increasing the size of whichever segment it lies in.

I tried by increasing the stack size.But it is not working . It is actually stopped due to segmentation fault with a debugger message "suspended: signal 'SIGSEGV' received".

It is declared as global variable. Is it due to some register related problem?

It would help a lot if we could see the code. Does the code compile with no errors and no warnings? .. global variables are not allocated on the stack.

It compile with no errors and no warnings.This is the part of code

#include<stdio.h>
#include<string.h>
#include "header.h"
#include "struct.h"

extern struct stack_rec stack[100];
extern char word[MAXWORD], mal_mean[MAXWORD], E_attr[MAXLEN], H_attr[CATLEN], semantic_tag[MAXWORD];
extern int word_cat, top, VOICE, prep_par, pos, phrase;

void getreltvform (char[], int);
void check_suffix (char[], int , int);
int p = 0;

/This function is used to resolve the meaning of relative pronouns and takes the formation with the word/

void resolve_reltvpronoun ()
{
char mmean[MAXWORD], means[5][MAXWORD];
int len = 0, i, clen = 0, ci = 0, spos = 0;

p = pos;
printf \("\\ninside resolve rel pronouunnn\\n"\);
if \(stack[top - 1].word_cat == KARAK && prep_par == 7\)
		spos = top - 2;
else
		spos = top - 1;

strcpy \(mmean, stack[spos].mal\);

len = strlen \(mmean\);
printf \("\\n\\nstack mal : %s\\n", mmean\);

stack[spos].mal[0] = '\\0';

for \(; i &lt; 5; i\+\+\)
		means[i][0] = '\\0';

for \(i = 0; mmean [i]!= '\\0'; i\+\+\)
	\{
  		if \(mmean [i]== '/'\)
	\{
  		means[clen\+\+][ci] = '\\0';
  		ci = 0;
	\}
  		else
		means[clen][ci\+\+] = mmean[i];
	\}
means[clen][ci] = '\\0';

for \(i = 0; i &lt;= clen; i\+\+\)
	getreltvform \(means[i], spos\);

stack[spos].mal[strlen \(stack[spos].mal\) - 1] = '\\0';
printf \("\\n final stack mallllllllll : %s", stack[spos].mal\);

}

segmention fault occur at the line -stack[spos].mal[0] = '\0';If we comment the line it will go to another line after that.
All the extern variables are declared in other files.

Sounds like spos is going out of bounds. Can you print out its value just before? How large is stack[] and how is it defined?

spos is getting some large number at the initialisation line(int spos=0) itself..How do this occur?How can i avoid this?

Are you sure? It's getting assigned a value one or two less than top a few lines later, and it's not at all clear where the value of top is coming from.

Post the definition of the stack_rec structure...what is its size?
What platform are you on and what are the ulimits for stack and data?

As an aside, proper architecting would dictate that you should write and debug a separate stack abstraction and access it only through a well-defined interface, rather than inline nitty-gritty stack handling into the main application logic. In the several days you have been struggling with this problem, I'm guessing you could have ripped out the stack operations and replaced them with a standard stack implementation (I hear the BOOST library has stuff like that for you).

Definition of stack_rec:

struct stack_rec {
int word_cat;
int phrase;
char word[60];
char mal[60];
char E_attr[60];
char H_attr[10];
char semantic_tag[60];
char connectors[3][16];
int cntrs_cnt;
int resolved;
int adj;
int adj_count;
};
allocated size 100 ..working in C. ulimit for stack is 10240

Can you add debugging printf statements to the code to see the value of top when the problematic function is entered, and perhaps elsewhere in the code where this value is modified?

On my system size of the stack_rec structure is 324 bytes...not sure where you are getting an allocated size of 100 and stack size of 10240 I'm assuming it's in kilobytes??

I think there is some confusion here from the compiler's use of stack (probably what the 10240 refers to) vs. the program's own implementation of an internal parsing stack, aka LIFO data structure.