#1726 panic "Bad tag priority being toggled on" using tkChat...

obsolete: 8.5a2
closed-fixed
9
2004-09-11
2004-06-26
No

Statement apparently causing the error:

tk::TextSetCursor .txt [tk::TextUpDownLine .txt -1]

Stack trace:

NTDLL! DbgBreakPoint address 0x77f7645c
Tcl_PanicVA(const char * 0x0033de74, char *
0x0012e1e4) line 96 + 44 bytes
Tcl_Panic(const char * 0x0033de74) line 133 + 13 bytes
TkTextIndexBackChars(const TkText * 0x01b727f0,
const TkTextIndex * 0x0012e40c, int 1, TkTextIndex *
0x0012e40c, int 3) line 1841 + 16 bytes
ForwBack(TkText * 0x01b727f0, const char *
0x01fd9ac7, TkTextIndex * 0x0012e40c) line 1200 + 21
bytes
GetIndex(Tcl_Interp * 0x008c6e18, TkText *
0x01b727f0, const char * 0x01fd9ac0, TkTextIndex *
0x0012e40c, int * 0x0012e41c) line 902 + 20 bytes
TkTextGetIndexFromObj(Tcl_Interp * 0x008c6e18,
TkText * 0x01b727f0, Tcl_Obj * 0x01fd9bb0) line 218 +
49 bytes
TextWidgetObjCmd(void * 0x01b727f0, Tcl_Interp *
0x008c6e18, int 3, Tcl_Obj * const * 0x008c7764) line
1145 + 20 bytes
TclEvalObjvInternal(Tcl_Interp * 0x008c6e18, int 3,
Tcl_Obj * const * 0x008c7764, const char *
0x00000000, int 0, int 0) line 3145 + 27 bytes
TclExecuteByteCode(Tcl_Interp * 0x008c6e18,
ByteCode * 0x02331e30) line 1672 + 39 bytes
TclCompEvalObj(Tcl_Interp * 0x008c6e18, Tcl_Obj *
0x00f68630) line 1011 + 13 bytes
TclObjInterpProc(void * 0x00f69c00, Tcl_Interp *
0x008c6e18, int 3, Tcl_Obj * const * 0x0012f66c) line
1088 + 19 bytes
TclEvalObjvInternal(Tcl_Interp * 0x008c6e18, int 3,
Tcl_Obj * const * 0x0012f66c, const char *
0x0012fbb9, int 26, int 0) line 3145 + 27 bytes
Tcl_EvalEx(Tcl_Interp * 0x008c6e18, const char *
0x0012fbb9, int 26, int 0) line 3644 + 39 bytes
TclSubstTokens(Tcl_Interp * 0x008c6e18, Tcl_Token *
0x0012f7fc, int 1, int * 0x00000000) line 2004 + 31 bytes
Tcl_EvalEx(Tcl_Interp * 0x008c6e18, const char *
0x0012fb9c, int 57, int 0) line 3568 + 31 bytes
Tcl_Eval(Tcl_Interp * 0x008c6e18, const char *
0x0012fb9c) line 3759 + 17 bytes
Tcl_GlobalEval(Tcl_Interp * 0x008c6e18, const char *
0x0012fb9c) line 4911 + 13 bytes
Tk_BindEvent(Tk_BindingTable_ * 0x008cf048, _XEvent
* 0x01fda1d8, Tk_Window_ * 0x01b72ba0, int 0, void *
* 0x0012fca8) line 1806 + 25 bytes
TkBindEventProc(TkWindow * 0x01b72ba0, _XEvent *
0x01fda1d8) line 286 + 31 bytes
Tk_HandleEvent(_XEvent * 0x01fda1d8) line 1064 + 13
bytes
WindowEventProc(Tcl_Event * 0x01fda1d0, int -3) line
1446 + 12 bytes
Tcl_ServiceEvent(int -3) line 624 + 13 bytes
Tcl_DoOneEvent(int -3) line 929 + 9 bytes
Tk_MainLoop() line 1627 + 15 bytes
Tk_MainEx(int 1, char * * 0x008d0060, int (Tcl_Interp *)
* 0x004010f3 Tcl_AppInit(Tcl_Interp *), Tcl_Interp *
0x008c6e18) line 299
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ *
0x00000000, char * 0x00133750, int 1) line 129 + 37
bytes
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32! GetProcessPriorityBoost + 279 bytes

-------------------

Code around the panic (in "generic/tkTextIndex.c" near
line #1841):

if (tagPtr->elideString != NULL) {
infoPtr->tagCnts[tagPtr->priority]
++;
if (infoPtr->tagCnts[tagPtr-
>priority] & 1) {
infoPtr->tagPtrs[tagPtr-
>priority] = tagPtr;
}
if (tagPtr->priority >= infoPtr-
>elidePriority) {
if (segPtr->typePtr ==
&tkTextToggleOnType) {
/*
* If it is being toggled
on, and it has
* an elide string, it must
actually be the
* current highest
priority tag, so this
* check is redundant:
*/
if (tagPtr->priority !=
infoPtr->elidePriority) {
Tcl_Panic("Bad
tag priority being toggled on");
}

/*
* Find previous elide
tag, if any (if not
* then elide will be zero,
of course).
*/
elide = 0;
while (--infoPtr-
>elidePriority > 0) {
if (infoPtr-
>tagCnts[infoPtr->elidePriority] & 1) {

Discussion

  • Anonymous

    Anonymous - 2004-06-26

    Logged In: YES
    user_id=585068

    I can duplicate this in NetBSD x86 with the HEAD of Tcl and
    Tk. Oddly when I first tried it with the HEAD of Tcl/Tk I
    used TkChat 1.158 and it didn't panic.

    With TkChat 1.158 the bug is that it stops scrolling. With
    TkChat 1.166 it results in a panic.

    To duplicate it click in the TkChat main text widget and
    then press up a few times.

     
  • Joe Mistachkin

    Joe Mistachkin - 2004-06-26
    • priority: 5 --> 9
     
  • Joe Mistachkin

    Joe Mistachkin - 2004-06-26

    Logged In: YES
    user_id=113501

    Crash is trivially reproducible on multiple operating systems
    and points to deeper issues, upping priority.

     
  • Anonymous

    Anonymous - 2004-08-29
    • labels: --> 18. [text]
    • assigned_to: nobody --> vincentdarley
     
  • Vince Darley

    Vince Darley - 2004-08-31

    Logged In: YES
    user_id=32170

    I can reproduce it, but hardly "trivially". It's going to
    be tricky to debug without a simpler example than all of
    tkchat with some history loaded...

    So, any efforts to produce a simpler example would be
    appreciated.

     
  • Vince Darley

    Vince Darley - 2004-08-31
    • status: open --> open-fixed
     
  • Vince Darley

    Vince Darley - 2004-08-31

    Logged In: YES
    user_id=32170

    Ok, I've resolved this. Here's the simplest test I could
    come to:

    text .txt -height 1 -wrap word -yscroll ".sbar set"
    -width 400
    scrollbar .sbar -command ".txt yview"
    grid .txt .sbar -sticky news
    grid configure .sbar -sticky ns
    grid rowconfigure . 0 -weight 1
    grid columnconfigure . 0 -weight 1
    .txt configure -width 10
    .txt tag config STAMP -elide 1
    .txt tag config NICK-tick -elide 0
    .txt insert end "+++++ Loading History ++++++++++++++++\n"
    .txt mark set HISTORY {2.0 - 1 line}
    .txt insert HISTORY { } STAMP
    .txt insert HISTORY {tick } {NICK NICK-tick}
    .txt insert HISTORY "\n" {NICK NICK-tick}
    .txt insert HISTORY {[23:51] } STAMP
    .txt insert HISTORY "\n" {NICK NICK-tick}
    # Must not crash
    .txt index "2.0 - 2 display lines"

    I have a fix, but it's currently intermingled with my
    tip#169 code, so I won't check it in right now.

     
  • Vince Darley

    Vince Darley - 2004-09-01

    Logged In: YES
    user_id=32170

    Note: for anyone who wants a fix. Go to
    TkTextIndexBackChars, and change the code after this comment to:

    /*
    * Find offset within seg that contains byteIndex.
    * Move backward specified number of chars.
    */

    lineIndex = -1;

    segSize = dstPtr->byteIndex;
    for (segPtr = dstPtr->linePtr->segPtr; ; segPtr =
    segPtr->nextPtr) {
    if (segSize <= segPtr->size) {
    if (checkElided && (segSize == segPtr->size)) {
    /*
    * We must get ourselves to the right position,
    * otherwise we'll get the elide count wrong
    */
    while (segPtr != infoPtr->segPtr) {
    segPtr = segPtr->nextPtr;
    }
    }
    break;
    }
    segSize -= segPtr->size;
    }

     
  • Vince Darley

    Vince Darley - 2004-09-10

    Logged In: YES
    user_id=32170

    This should now be fixed in cvs HEAD. Please do test....

     
  • Anonymous

    Anonymous - 2004-09-11
    • status: open-fixed --> closed-fixed
     
  • Anonymous

    Anonymous - 2004-09-11

    Logged In: YES
    user_id=585068

    It seems to be fixed in the HEAD. Thanks Vince.