Tk Source Code

View Ticket
Login
Ticket UUID: 837300
Title: Infinite sequences of events in tkTextDisp.c
Type: Bug Version: obsolete: 8.5a0
Submitter: dkf Created on: 2003-11-06 15:51:37
Subsystem: 18. [text] Assigned To: dkf
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2003-11-15 00:31:46
Resolution: Fixed Closed By: dkf
    Closed on: 2003-11-14 17:31:46
Description:
The test file textDisp.test hangs in a state where it
is still handling events while executing textDisp-9.2
on Linux/*x86 with display sent to an SGI O2 running
IRIX6.5 over SSH.  This is *bad* since it impacts upon
the whole test suite's running to completion!
User Comments: dkf added on 2003-11-15 00:31:46:
Logged In: YES 
user_id=79902

That fixes that fault, but I run into another problem on the
very next test.  This time, we're not finishing the
line-metric update loop because we're getting into trouble
over the processing of the invisible last line, triggered by
invalidating the entire text widget (which happens in
textDisp-9.3)

Luckily, this is a fault that I understand how it happens
and how to fix it. (TkTextUpdateLineMetrics actually has
code in to detect the case; it just needs to return the
right value of result line to make sure that the update
terminatesm which is coincidentally an argument to the
function.)

Everything fixed now. The test suite completes (and the only
text-widget related failure seems to be font related.)

vincentdarley added on 2003-11-14 15:43:53:
Logged In: YES 
user_id=32170

Great!  Try changing that block to:

    if (tagPtr->affectsDisplayGeometry) {
        TkTextLine *startLine, *endLine;
int lineCount;
if (index2Ptr == NULL) {
    endLine = NULL;
    lineCount = TkBTreeNumLines(textPtr->tree);
} else {
    endLine = index2Ptr->linePtr;
    lineCount = TkBTreeLineIndex(endLine);
}
if (index1Ptr == NULL) {
    startLine = NULL;
} else {
    startLine = index1Ptr->linePtr;
    lineCount -= TkBTreeLineIndex(startLine);
}
TkTextInvalidateLineMetrics(textPtr, startLine, lineCount, 
    TK_TEXT_INVALIDATE_ONLY);
    }

dkf added on 2003-11-14 02:27:30:
Logged In: YES 
user_id=79902

Ah!  Found it!  (I can't use the crashing trick because of
stupid local misconfiguration issues; some idiot sysadmin
has disabled coredumps for *everyone* except root...)

In TkTextRedrawTag, there's a call to
TkTextInvalidateLineMetrics. The code to figure out how many
lines to be invalidated is bogus since endLine and startLine
are both pointers, not integers...

vincentdarley added on 2003-11-13 23:57:11:
Logged In: YES 
user_id=32170

Here's a debugging suggestion.  Add some code to panic if
lastMetricUpdateLine is not in a reasonable range (-1 to
1000 ought to be fine for the test suite), and perhaps
you'll be able to see the circumstances when it all goes
wrong...

nobody added on 2003-11-12 15:39:14:
Logged In: NO 

Well, it's good you seem to have identified it as a bug in
tkTextDisp.c.  Unless I have a reproducible test case on
hand, there's very little chance I can resolve it (I looked
through the code, and no obvious problem reared it's head).
So, I think you'll need to look through those interactions
between TTAULM and TTILM, particularly at
lastMetricUpdateLane and currentMetricUpdateLine and see
what goes wrong...

dkf added on 2003-11-12 03:26:42:
Logged In: YES 
user_id=79902

Hmm.  Looks like a bogus value in
dInfoPtr->lastMetricUpdateLine (or at least 214750521 isn't
obviously anything, not even a pointer or string.)  I've no
idea where that's coming from, but it looks like a nasty
interaction between TTAULM and TTILM (which is
TkTextInvalidateLineMetrics of course)

nobody added on 2003-11-12 02:56:56:
Logged In: NO 

Hmm, then you'll have to help me understand what it's doing
in that infinite loop --- what lines is it recalculating,
for example?  The code is designed to stop the asychronous
calculations once it has gathered all the info it needs.

dkf added on 2003-11-12 01:33:10:
Logged In: YES 
user_id=79902

It can reschedule itself.  It's just got to take care that
it's going to eventually stop even with substantial delays
in the system.

vincentdarley added on 2003-11-11 16:35:01:
Logged In: YES 
user_id=32170

I see -- I guess this means the Tcl bug where idle callbacks
are not allowed to reschedule themselves (since they just
cause an infinite loop) also applies to timer callbacks, then.

I don't know what the right solution is. We can obviously
increase the delay between each timer callback, but for a
sufficient network delay, the same bug will always occur,
until the fundamental Tcl bug is resolved.

dkf added on 2003-11-11 03:47:40:
Logged In: YES 
user_id=79902

Hmm.  Looking at the code a bit further, I've found that the
problem is an infinite repetition of
TkTextAsyncUpdateLineMetrics, and the difference between
your configuration and mine might simply be that I've got
enough round-trip delay (currently transatlantic over
encrypted connection!) in my system for the effect to kick in.

vincentdarley added on 2003-11-07 22:53:12:
Logged In: YES 
user_id=32170

The new text widget does schedule timer events (to do the
asynchronous pixel height and scrollbar update
calculations), so it is possible that they are involved here.

I can't really debug, since I don't see that.

dkf added on 2003-11-07 21:51:48:
Logged In: YES 
user_id=79902

Hmm.  It seems to be spinning around the loop in
Tk_UpdateObjCmd; why is Tcl_DoOneEvent always returning
non-zero?  Is this because there's a never-ending stream of
events to process?  Who is generating all the events?  What
are they?  Why is this happening?  :^(

dkf added on 2003-11-07 21:35:35:
Logged In: YES 
user_id=79902

Deeper inspection indicates that the redraw has completed
correctly.  WTF is going on!?  All instrumentation indicates
correct behaviour, but [update] still isn't returning... >:^(

dkf added on 2003-11-07 21:16:52:
Logged In: YES 
user_id=79902

Simple instrumentation indicates that the problem happens
during the second [update] in textDisp-9.2

dkf added on 2003-11-07 20:59:17:
Logged In: YES 
user_id=79902

I don't know where to start.

It's not a crash, and the text widget window permits editing
so obviously events are being handled.  It looks like it
goes into an infinite loop somewhere one of the times
[update] is called.

vincentdarley added on 2003-11-07 18:38:33:
Logged In: YES 
user_id=32170

Can you debug this -- it is clearly specific to a rather
particular situation that I have no chance of replicating...