Path: utzoo!utgpu!news-server.csri.toronto.edu!smoke.cs.toronto.edu!neat.cs.toronto.edu!moraes Newsgroups: comp.windows.x From: moraes@cs.toronto.edu (Mark Moraes) Subject: Re: Xterm dies in tek mode Message-ID: <90Sep17.174858edt.382@smoke.cs.toronto.edu> Organization: Department of Computer Science, University of Toronto References: <167855@teemc.UUCP> Date: 17 Sep 90 21:49:58 GMT Lines: 106 wayne@teemc.UUCP (Michael R. Wayne) writes: > Every time I try to use xterm in tek mode, it dies. gdb on xterm -t >tells me the problem is in the library routine XmuCopyISOLatinLowered called >from TekRealize at line 1292 of xterm/Tekproc.c. Is there a patch to deal >with this one? Here's a copy of a bug report we filed with xbugs in January -- strictly unblessed and unsupported, of course! From: jonah@dgp.toronto.edu To: xbugs@expo.lcs.mit.edu Subject: xterm core dumps when openning tek window X Window System Bug Report xbugs@expo.lcs.mit.edu VERSION: R4 CLIENT MACHINE and OPERATING SYSTEM: Sun 3/280 running SunOS 3.5 DISPLAY TYPE: Sun /dev/fb (mono) WINDOW MANAGER: twm AREA: xterm/Xaw/Xmu/Xt SYNOPSIS: When I try to open the tek window in xterm, xterm just quits with a "memory fault" DESCRIPTION: In Texproc.c, XmuCopyISOLatin1Lowered is called with the same string for the source and destination -- but the string comes from the toolkit and might be a static (non-writable) string. (gdb) bt #0 0x1734c in XmuCopyISOLatin1Lowered () #1 0x1013a in TekRun () #2 0x22fd8 in _XtIsSubclassOf () #3 0x23074 in _XtIsSubclassOf () #4 0x23108 in XtRealizeWidget () #5 0xfa1e in TekRun () #6 0x3824 in main () REPEAT BY: Compile xterm, Xaw, Xt, and Xmu with gcc (1.35) but without -fwritable-strings. Start-up an xterm and try to open a tek window from the menu. Run gdb and look at the backtrace. Note: Before you get to this bug, you may have to compensate for the fact that many libraries have a broken sscanf() which may also try to modify a ``const'' (ANSI C) string argument. We'd send you the fix to this one too, but it's a patch to non-redistributable code. SAMPLE FIX: *** /tmp/,RCSt1a00417 Thu Jan 18 21:48:06 1990 --- mit/clients/xterm/Tekproc.c Thu Jan 18 21:18:14 1990 *************** *** 1288,1303 **** screen->cur.fontsize = TEK_FONT_LARGE; if (tw->tek.initial_font) { char *s = tw->tek.initial_font; ! XmuCopyISOLatin1Lowered (s, s); ! if (strcmp (s, "large") == 0) screen->cur.fontsize = TEK_FONT_LARGE; ! else if (strcmp (s, "2") == 0 || strcmp (s, "two") == 0) screen->cur.fontsize = TEK_FONT_2; ! else if (strcmp (s, "3") == 0 || strcmp (s, "three") == 0) screen->cur.fontsize = TEK_FONT_3; ! else if (strcmp (s, "small") == 0) screen->cur.fontsize = TEK_FONT_SMALL; } gcv.graphics_exposures = TRUE; /* default */ --- 1288,1309 ---- screen->cur.fontsize = TEK_FONT_LARGE; if (tw->tek.initial_font) { char *s = tw->tek.initial_font; + char *slow = (char*) malloc(strlen(s)+1); ! if (slow == (char*)NULL) { ! fprintf(stderr, "%s: malloc failed\n", xterm_name); ! goto mallocfailed; ! } ! XmuCopyISOLatin1Lowered (slow, s); ! if (strcmp (slow, "large") == 0) screen->cur.fontsize = TEK_FONT_LARGE; ! else if (strcmp (slow, "2") == 0 || strcmp (slow, "two") == 0) screen->cur.fontsize = TEK_FONT_2; ! else if (strcmp (slow, "3") == 0 || strcmp (slow, "three") == 0) screen->cur.fontsize = TEK_FONT_3; ! else if (strcmp (slow, "small") == 0) screen->cur.fontsize = TEK_FONT_SMALL; + free(slow); } gcv.graphics_exposures = TRUE; /* default */