[comp.sys.dec] Bus error, help!

andrewd@cs.tamu.edu (Andrew Ted Duchowski) (02/27/91)

Greetings,

Could someone help me with the following problem:

In the following function, the line delimitted by 
/* problem line */ gives me:

  Bus error [malloc:445, 0x....]

but *only* on the first call from a paritular function.
Let's call that function ftn1.  To sate the symptoms
clearly, the program dumps when I click first on a button
that executes ftn1 which calls create_value.  If however, 
I click on a different button such that ftn2 calls create_value 
first, and then I click a button so that ftn1 calls create_value, no
dump.  Only when I click on the button so that ftn1 calls 
create_value first do I get the dump.

I've checked args, and they look ok, so I don't think that's
the faulty parameter.  Can anyone give me any clues why
create_value dumps where and when it does?  I've been looking
at this for about a week, read the DEC manuals for both relevant
Dwt (DEC widgets) and XUI Toolkit widgets, and create_value 
appears fine, straight out of the textbook.  What am I doing wrong?

I'm on a DECstation3100 running Ultrix 4.1.  
Thanks a bunch in advance, please reply to andrewd@cs.tamu.edu
Andrew
andrewd@cs.tamu.edu
------------------------------------------------
Widget create_value(parent,str)
Widget parent;
char *str;
{
  int i=0;
  Arg args[4];
  Widget box,value;

  XtSetArg(args[0],DwtNresize,DwtResizeShrinkWrap);
  box = DwtDialogBoxCreate(parent,"textbox",args,1);
  XtManageChild(box);

  XtSetArg(args[i],DwtNinsertionPointVisible,False); i++;
  XtSetArg(args[i],DwtNborderWidth,0); i++;
  XtSetArg(args[i],DwtNhalfBorder,False); i++;
  XtSetArg(args[i],DwtNvalue,str); i++;

/* problem line */
  value = DwtSTextCreate(box,"textvalue",args,i);
/* problem line */
  XtAddCallback(value,DwtNfocusCallback,gainfocus,0);
  XtAddCallback(value,DwtNlostFocusCallback,losefocus,0);
  XtManageChild(value);

  return value;
}
--

-------------- Not an Official Texas A&M University Document --------------