On 11/27/2016 11:02 AM, Ken Brown wrote: > On 11/27/2016 9:03 AM, Girish Joglekar wrote: >> Hi Ken, >> Thank you for your reply on the Cygwin mailing list. I have created a >> slightly smaller test example smaller than what I had created in Feb. >> Attached is a tar file. After make insall if you run TEST.x and click >> the Open button, it gives segmentation fault. >> Hope you will be able to help. >> Thank you. >> Girish > > Please keep the discussion on the mailing list so that people who might > be able to help will see it. I personally am not familiar with X11 > programming, so I'm not one of those people. > > I do have a few comments, however: > > 1. This may be slightly smaller than your previous program, but it is > still *very* far from a small test case. You really can't expect people > to debug a program of this size for you. > > 2. I suggest that you build with -Wall (as Marco already suggested in > the earlier discussion) and fix all the compiler warnings. I saw > several that need attention (aside from the many "unused variable" > warnings). It wouldn't hurt to also use -Wextra. > > 3. I also suggest that you use gdb to find out where the program is > crashing and why. You made a start on that in the discussion last > March, but you didn't follow through. (By the way, I recommend building > without optimization; otherwise you may not be able to get accurate > information about the crash from gdb.) > > 4. If, after the steps above, you still think the crash is due to a > Cygwin bug rather than a programming error, then try to extract from > your program a test case as small as possible that reproduces the crash.
I've looked at this a little, and the crash occurs because of a bad value of a pointer to a font list. I'm attaching an annotated transcript of a gdb session that illustrates this. I didn't try to figure out where the bad pointer came from. As a workaround, you can avoid the crash by removing from mosprshx.c all uses of spreadSheetFont, as in the following patch: --- mosprshx.c~ 2016-11-27 08:46:12.000000000 -0500 +++ mosprshx.c 2016-11-29 14:58:23.114377500 -0500 @@ -29,8 +29,6 @@ 0x00, 0x7c, 0x07, 0x1e, 0x0f, 0x07, 0x9e, 0x03, 0xfc, 0x01, 0xf8, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00}; -static char *spreadSheetFont = "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1"; - #ifdef __STDC__ static void mosprshCreateCheckMarkPixmap(Widget pushButton) #else @@ -208,11 +206,6 @@ if(isParentManaged) XtUnmanageChild(parentFM); - fromValue.addr = spreadSheetFont; - fromValue.size = utStringLength(fromValue.addr) + 1; - toValue.addr = NULL; - XtConvertAndStore(parentFM,XmRString,&fromValue,XmRFontList,&toValue); - ac = 0; XtSetArg(al[ac],XmNuserData,(XtPointer)spreadSheetSize); ac++; spreadSheet = XmCreateForm(parentFM,"SpreadSheet",al,ac); @@ -234,9 +227,6 @@ XtSetArg(al[ac],XmNtraversalOn,FALSE); ac++; } XtSetArg(al[ac],XmNcolumns,longestFixedColumnSize+1); ac++; - if(toValue.addr) { - XtSetArg(al[ac],XmNfontList,*(unsigned int *)toValue.addr); ac++; - } for(i1=0 ; i1<nRows ; i1++) { sprintf(widgetName,"fixedColumnRow%d",i1); fixedColumnTF[i1] = XmCreateTextField(fixedColumn,widgetName,al,ac); @@ -264,9 +254,6 @@ if(cellSize > 0) { XtSetArg(al[ac],XmNcolumns,cellSize); ac++; } - if(toValue.addr) { - XtSetArg(al[ac],XmNfontList,*(unsigned int *)toValue.addr); ac++; - } for(j1=0 ; j1<nColumns ; j1++) { sprintf(widgetName,"fixedRowColumn%d",j1); fixedRowTF[j1] = XmCreateTextField(fixedRow,widgetName,al,ac); @@ -294,9 +281,6 @@ XtSetArg(al[ac],XmNcolumns,cellSize); ac++; XtSetArg(al[ac],XmNmaxLength,cellSize); ac++; } - if(toValue.addr) { - XtSetArg(al[ac],XmNfontList,*(unsigned int *)toValue.addr); ac++; - } sprintf(widgetName,"column%drow%d",j1,i1); variableRowAndColumnTF[loc] = XmCreateTextField(variableColumnFM[j1],widgetName,al,ac); loc++; } @@ -886,15 +870,3 @@ *nColumns = 0; } } - - -#ifdef __STDC__ -char *moGetSpreadsheetFont() -#else -char *moGetSpreadsheetFont() -#endif -{ - return(spreadSheetFont); -} - - Ken
Thread 1 "TEST.x" received signal SIGSEGV, Segmentation fault. 0x00000003fc68c4e5 in XmRenderTableCopy (table=0xaeeb0, tags=tags@entry=0x0, tag_count=tag_count@entry=0) at /usr/src/debug/motif-2.3.6-1/lib/Xm/XmRenderT.c:1709 1709 if (_XmRTDisplay(table)) [Crash here because the value of table is bogus. See below. +bt #0 0x00000003fc68c4e5 in XmRenderTableCopy (table=0xaeeb0, tags=tags@entry=0x0, tag_count=tag_count@entry=0) at /usr/src/debug/motif-2.3.6-1/lib/Xm/XmRenderT.c:1709 #1 0x00000003fc6831ba in XmFontListCopy (fontlist=<optimized out>) at /usr/src/debug/motif-2.3.6-1/lib/Xm/XmFontList.c:637 #2 0x00000003fc657920 in InitializeTextStruct (tf=tf@entry=0x6000af730) at /usr/src/debug/motif-2.3.6-1/lib/Xm/TextF.c:7295 #3 0x00000003fc657e67 in Initialize (request=request@entry=0x6000afb40, new_w=new_w@entry=0x6000af730, args=args@entry=0xffffbd60, num_args=num_args@entry=0xffffb320) at /usr/src/debug/motif-2.3.6-1/lib/Xm/TextF.c:7817 #4 0x00000003fc469bb1 in CallInitialize ( class=0x3fc72c440 <xmTextFieldClassRec>, req_widget=req_widget@entry=0x6000afb40, new_widget=new_widget@entry=0x6000af730, args=args@entry=0xffffbd60, num_args=num_args@entry=8) at /usr/src/debug/libXt-1.1.5-1/src/Create.c:226 #5 0x00000003fc46a65c in xtCreate ( name=name@entry=0xffffb950 "fixedColumnRow0", class=class@entry=0x0, widget_class=widget_class@entry=0x3fc72c440 <xmTextFieldClassRec>, parent=0x1fc5dd590, parent@entry=0x6000af0d0, default_screen=0x600052780, args=args@entry=0xffffbd60, num_args=num_args@entry=8, typed_args=typed_args@entry=0x0, num_typed_args=num_typed_args@entry=0, parent_constraint_class=0x3fc720dc0 <xmFormClassRec>, post_proc=post_proc@entry=0x3fc469bf0 <widgetPostProc>) at /usr/src/debug/libXt-1.1.5-1/src/Create.c:416 #6 0x00000003fc46a906 in _XtCreateWidget ( name=name@entry=0xffffb950 "fixedColumnRow0", widget_class=widget_class@entry=0x3fc72c440 <xmTextFieldClassRec>, parent=parent@entry=0x6000af0d0, args=args@entry=0xffffbd60, num_args=num_args@entry=8, typed_args=typed_args@entry=0x0, num_typed_args=num_typed_args@entry=0) at /usr/src/debug/libXt-1.1.5-1/src/Create.c:570 #7 0x00000003fc46abd9 in XtCreateWidget (name=0xffffb950 "fixedColumnRow0", widget_class=0x3fc72c440 <xmTextFieldClassRec>, parent=0x6000af0d0, args=0xffffbd60, num_args=8) at /usr/src/debug/libXt-1.1.5-1/src/Create.c:589 #8 0x00000003fc658a81 in XmCreateTextField (parent=<optimized out>, name=<optimized out>, arglist=<optimized out>, argcount=<optimized out>) at /usr/src/debug/motif-2.3.6-1/lib/Xm/TextF.c:10645 #9 0x000000010040882d in mosprshCreateSpreadsheet (parentFM=0x6000acc60, spreadSheetTitle=0x100421087 "Measuring Unit Specification", rowNames=0x6000ab4f0, columnNames=0x6000ab4b0, cellSize=0, mosprshCheckButtonCallback=0x0) at mosprshx.c:242 [...] +p *table $1 = (struct __XmRenderTableRec *) 0x56f700001ea1 +p *$ Cannot access memory at address 0x56f700001ea1 +f 2 #2 0x00000003fc657920 in InitializeTextStruct (tf=tf@entry=0x6000af730) at /usr/src/debug/motif-2.3.6-1/lib/Xm/TextF.c:7295 7295 TextF_FontList(tf) = (XmFontList)XmFontListCopy(TextF_FontList(tf)); +p tf->text.font_list $2 = (XmFontList) 0xaeeb0 [This is the bad pointer that was propagated to XmRenderTableCopy. I didn't chase down where it came from.]
-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple