[5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
38 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Tim Johnson-2
Hi,

A class with styled text in its class comment, when a user mouses around
in the text, can eventually trigger endless subscript out-of-bounds
windows to pop up, requiring Cmd-. and 'close all windows like this'.  
(The styled text may have entered the class comment from a user pasting
Shout-styled text from a method into the class comment.)

I have run into this one before but never pinpointed a cause.  This has
probably been broken for some time.  I have updated my image to #18134
and it still has the problem.  It may be related to a class with styled
text being exported from one image and imported into another.

Maybe this would be a good one for a Mantis report.

How to reproduce:

1. File-in the .cs as attached*.
2. In a system browser, click on the class, then click on the [?] button
to view class comment.
3. Notice the styled text in the comment.
4. Click around the comment pane a bit.
5. Eventually, see "Error: subscript is out of bounds: 71" appear over
and over until you interrupt.

* this .cs is a slimmed-down and hand-edited version of a real file-out
of a real class which was exhibiting this problem.  In preparing the .cs
for this mailing, I've shortened the class name by three characters.  If
you notice the "style[(1 35 18 20 3),f1,,b," doesn't match, this may be
why.

.cs file and stack follow.

Thanks,
Tim

ByteString(Object)>>error:
ByteString(Object)>>errorSubscriptBounds:
ByteString(Object)>>at:
ByteString>>at:
CharacterBlockScanner(CharacterScanner)>>basicScanByteCharactersFrom:to:in:rightX:
CharacterBlockScanner(CharacterScanner)>>primScanCharactersFrom:to:in:rightX:stopConditions:kern:
CharacterBlockScanner(CharacterScanner)>>scanByteCharactersFrom:to:in:rightX:
StrikeFont(AbstractFont)>>scanByteCharactersFrom:to:in:with:rightX:
ByteString>>scanCharactersFrom:to:with:rightX:font:
CharacterBlockScanner(CharacterScanner)>>scanCharactersFrom:to:in:rightX:
CharacterBlockScanner>>characterBlockAtPoint:index:in:
NewParagraph>>characterBlockForIndex:
SmalltalkEditor(TextEditor)>>markIndex:pointIndex:
SmalltalkEditor(Editor)>>selectInvisiblyFrom:to:
SmalltalkEditor(TextEditor)>>selectFrom:to:
SmalltalkEditor(Editor)>>selectInterval:
PluggableTextMorphPlus(PluggableTextMorph)>>mouseEnter:
PluggableTextMorphPlus(Morph)>>handleMouseEnter:
MouseMoveEvent(MouseEvent)>>sentTo:
MouseMoveEvent>>sentTo:
PluggableTextMorphPlus(Morph)>>handleEvent:
[] in MouseOverHandler>>processMouseOver:
Array(SequenceableCollection)>>reverseDo:
MouseOverHandler>>processMouseOver:
HandMorph>>handleEvent:
HandMorph>>processEvents
[] in WorldState>>doOneCycleNowFor:
Array(SequenceableCollection)>>do:
WorldState>>handsDo:
WorldState>>doOneCycleNowFor:
WorldState>>doOneCycleFor:
PasteUpMorph>>doOneCycle
[] in MorphicProject>>spawnNewProcess
[] in BlockClosure>>newProcess



FooClient.cs (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Edgar De Cleene
And still we do not have a 5.2 tag for Mantis...
Maybe we should revive the sending [BUG] reports from image here.
Or open a BUGReports Mail list somewhere so easy to find out things.


Edgar
@morplenauta



On 02/07/2018, 20:10, "Tim Johnson" <[hidden email]> wrote:

> Maybe this would be a good one for a Mantis report.



Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Tobias Pape
Hi Edgar


> On 03.07.2018, at 10:33, Edgar J. De Cleene <[hidden email]> wrote:
>
> And still we do not have a 5.2 tag for Mantis...

Sorry, but not sorry. I have no time to look at mantis.

I don't know who else has admin there, too.
Do you want?
        -t

> Maybe we should revive the sending [BUG] reports from image here.
> Or open a BUGReports Mail list somewhere so easy to find out things.
>
>
> Edgar
> @morplenauta
>
>
>
> On 02/07/2018, 20:10, "Tim Johnson" <[hidden email]> wrote:
>
>> Maybe this would be a good one for a Mantis report.
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

K K Subbu
In reply to this post by Tim Johnson-2
On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
> ByteString(Object)>>error:
> ByteString(Object)>>errorSubscriptBounds:
> ByteString(Object)>>at:
> ByteString>>at:
> CharacterBlockScanner(CharacterScanner)>>basicScanByteCharactersFrom:to:in:rightX:

The following code in basicScan... doesn't look right:
-----
        lastIndex := startIndex.
        [lastIndex <= stopIndex]
                whileTrue: [
                        "get the character value"
                        char := sourceString at: lastIndex.
---
stopIndex can exceed sourceString size, so the comparison should be <
and not <=. This may trigger an error when sourceString ends in styled text.

With the attached patch, I no longer get the error. But I am not sure if
my diagnosis is right.

HTH .. Subbu



fixscanner.1.cs (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Edgar De Cleene
In reply to this post by Tobias Pape
Yes please
I like too have a 5.2 tag and start to collect bugs relevant to this release


On 03/07/2018, 06:07, "Tobias Pape" <[hidden email]> wrote:

> Sorry, but not sorry. I have no time to look at mantis.

I don't know who else
> has admin there, too.
Do you want?
 -t



Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Tobias Pape

> On 03.07.2018, at 12:27, Edgar J. De Cleene <[hidden email]> wrote:
>
> Yes please
> I like too have a 5.2 tag and start to collect bugs relevant to this release
>
have a look if its ok.


>
> On 03/07/2018, 06:07, "Tobias Pape" <[hidden email]> wrote:
>
>> Sorry, but not sorry. I have no time to look at mantis.
>
> I don't know who else
>> has admin there, too.
> Do you want?
> -t
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Karl Ramberg
In reply to this post by Tim Johnson-2
Weird error.
See Debugger in attachment,
How come selectionInterval and interval is different ?

Best,
Karl

On Tue, Jul 3, 2018 at 1:10 AM Tim Johnson <[hidden email]> wrote:
Hi,

A class with styled text in its class comment, when a user mouses around
in the text, can eventually trigger endless subscript out-of-bounds
windows to pop up, requiring Cmd-. and 'close all windows like this'. 
(The styled text may have entered the class comment from a user pasting
Shout-styled text from a method into the class comment.)

I have run into this one before but never pinpointed a cause.  This has
probably been broken for some time.  I have updated my image to #18134
and it still has the problem.  It may be related to a class with styled
text being exported from one image and imported into another.

Maybe this would be a good one for a Mantis report.

How to reproduce:

1. File-in the .cs as attached*.
2. In a system browser, click on the class, then click on the [?] button
to view class comment.
3. Notice the styled text in the comment.
4. Click around the comment pane a bit.
5. Eventually, see "Error: subscript is out of bounds: 71" appear over
and over until you interrupt.

* this .cs is a slimmed-down and hand-edited version of a real file-out
of a real class which was exhibiting this problem.  In preparing the .cs
for this mailing, I've shortened the class name by three characters.  If
you notice the "style[(1 35 18 20 3),f1,,b," doesn't match, this may be
why.

.cs file and stack follow.

Thanks,
Tim

ByteString(Object)>>error:
ByteString(Object)>>errorSubscriptBounds:
ByteString(Object)>>at:
ByteString>>at:
CharacterBlockScanner(CharacterScanner)>>basicScanByteCharactersFrom:to:in:rightX:
CharacterBlockScanner(CharacterScanner)>>primScanCharactersFrom:to:in:rightX:stopConditions:kern:
CharacterBlockScanner(CharacterScanner)>>scanByteCharactersFrom:to:in:rightX:
StrikeFont(AbstractFont)>>scanByteCharactersFrom:to:in:with:rightX:
ByteString>>scanCharactersFrom:to:with:rightX:font:
CharacterBlockScanner(CharacterScanner)>>scanCharactersFrom:to:in:rightX:
CharacterBlockScanner>>characterBlockAtPoint:index:in:
NewParagraph>>characterBlockForIndex:
SmalltalkEditor(TextEditor)>>markIndex:pointIndex:
SmalltalkEditor(Editor)>>selectInvisiblyFrom:to:
SmalltalkEditor(TextEditor)>>selectFrom:to:
SmalltalkEditor(Editor)>>selectInterval:
PluggableTextMorphPlus(PluggableTextMorph)>>mouseEnter:
PluggableTextMorphPlus(Morph)>>handleMouseEnter:
MouseMoveEvent(MouseEvent)>>sentTo:
MouseMoveEvent>>sentTo:
PluggableTextMorphPlus(Morph)>>handleEvent:
[] in MouseOverHandler>>processMouseOver:
Array(SequenceableCollection)>>reverseDo:
MouseOverHandler>>processMouseOver:
HandMorph>>handleEvent:
HandMorph>>processEvents
[] in WorldState>>doOneCycleNowFor:
Array(SequenceableCollection)>>do:
WorldState>>handsDo:
WorldState>>doOneCycleNowFor:
WorldState>>doOneCycleFor:
PasteUpMorph>>doOneCycle
[] in MorphicProject>>spawnNewProcess
[] in BlockClosure>>newProcess




Sketch.jpeg (97K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

K K Subbu
On Wednesday 04 July 2018 12:04 AM, karl ramberg wrote:
> Weird error.
> See Debugger in attachment,
> How come selectionInterval and interval is different ?
I couldn't reproduce this error. I suspect the difference can be
explained because of recursive error trigger.

I noticed that there were many error windows on top of each other making
them appear like one. See Main Menu -> Windows. In recursive error, it
is possible for local ivar interval to differ from instance var
selectionInterval.  The debug stack trace is different for each one.

Regards .. Subbu

Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

K K Subbu
In reply to this post by Tim Johnson-2
On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
> 1. File-in the .cs as attached*.
> 2. In a system browser, click on the class, then click on the [?] button
> to view class comment.
> 3. Notice the styled text in the comment.
> 4. Click around the comment pane a bit.
> 5. Eventually, see "Error: subscript is out of bounds: 71" appear over
> and over until you interrupt.
In step 4, it is sufficient to click once near the bottom of the pane
when the cursor changes from I-bar to arrow and then wait. This will
trigger the error, but the error window triggers itself recursively
around 50 times before stopping and displaying the windows.

I added an assert to catch it before recursion:

    self assert: lastIndex < sourceString size.

The assert window itself throws up another error, but that is a topic
for another thread ;-).

Regards .. Subbu

Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Karl Ramberg
Hi,
See class comment i NewParagraph for a hint of what happens.
A empty lineSpan 71 to: 70 is added to the end of the paragraph, when you double click below the text.
When the character scanner looks for characters outside of the string at index 71 it cause a recursion.

Best,
Karl



On Wed, Jul 4, 2018 at 11:10 AM K K Subbu <[hidden email]> wrote:
On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
> 1. File-in the .cs as attached*.
> 2. In a system browser, click on the class, then click on the [?] button
> to view class comment.
> 3. Notice the styled text in the comment.
> 4. Click around the comment pane a bit.
> 5. Eventually, see "Error: subscript is out of bounds: 71" appear over
> and over until you interrupt.
In step 4, it is sufficient to click once near the bottom of the pane
when the cursor changes from I-bar to arrow and then wait. This will
trigger the error, but the error window triggers itself recursively
around 50 times before stopping and displaying the windows.

I added an assert to catch it before recursion:

    self assert: lastIndex < sourceString size.

The assert window itself throws up another error, but that is a topic
for another thread ;-).

Regards .. Subbu



Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

David T. Lewis
On Wed, Jul 04, 2018 at 02:35:59PM +0200, karl ramberg wrote:

>
> On Wed, Jul 4, 2018 at 11:10 AM K K Subbu <[hidden email]> wrote:
>
> > On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
> > > 1. File-in the .cs as attached*.
> > > 2. In a system browser, click on the class, then click on the [?] button
> > > to view class comment.
> > > 3. Notice the styled text in the comment.
> > > 4. Click around the comment pane a bit.
> > > 5. Eventually, see "Error: subscript is out of bounds: 71" appear over
> > > and over until you interrupt.
> > In step 4, it is sufficient to click once near the bottom of the pane
> > when the cursor changes from I-bar to arrow and then wait. This will
> > trigger the error, but the error window triggers itself recursively
> > around 50 times before stopping and displaying the windows.
> >
> > I added an assert to catch it before recursion:
> >
> >     self assert: lastIndex < sourceString size.
> >
> > The assert window itself throws up another error, but that is a topic
> > for another thread ;-).
> >
> > Regards .. Subbu

>
> Hi,
> See class comment i NewParagraph for a hint of what happens.
> A empty lineSpan 71 to: 70 is added to the end of the paragraph, when you
> double click below the text.
> When the character scanner looks for characters outside of the string at
> index 71 it cause a recursion.
>
> Best,
> Karl
>

Good tiip to look at the NewParagraph class comment, there is apparently
some left over messiness in here somewhere.

Another way to trigger the bug using the test case with FooClient is
to position the cursor in the comment pane and use keyboard right cursor
to move to the end of the comment. This causes the same bounds error but
takes a different path through the code leading to the error.

Looking through the stack in a debugger after triggering the error with
the mouse, here are a few notes (but no conclusions):

On mouseUp: we enter Editor>>selectWord then call Editor>>selectWordLeftDelimiters:rightDelimiters:
which has this:

        "Select the whole text when clicking before first or after last character"
        (here > string size or: [here < 2]) ifTrue: [^self selectFrom: 1 to: string size].

where string is the 70 character String derived from the Text.

At this point we are trying to select from 1 to 70 (the whole string for
the entire text) in TextEditor>>selectFrom:to:

This calls Editor>>selectInvisiblyFrom:to: and here the stop index is
set past the size of the string:

  selectInvisiblyFrom: start to: stop
     "Select the designated characters, inclusive.  Make no visual changes."

     self markIndex: start pointIndex: stop + 1

From this point we are trying to go from index 1 to index 71 over a string
of size 70, and eventually end up with the out of bounds exception.

A clue that this might be accumulation of kludges: Looking at senders of
selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a number
of methods that subtract 1 from the stop index when before calling the method
that adds 1 back to the stop index. This certainly does not have a good smell.

It is not clear to me why selectInvisiblyFrom:to: would be adding one to the
stop index, but I see that the method stamp is jmv 5/27/2011, which suggests
to me that we should take a look at Cuis to figure out how this is intended
to function. Cuis does not show any cases of senders of selectInvisiblyFrom:to:
that subtract 1 from the stop index, and the Cuis implementation of
selectInvisiblyFrom:to: is that same as Squeak.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

David T. Lewis
On Wed, Jul 04, 2018 at 11:53:15AM -0400, David T. Lewis wrote:

> On Wed, Jul 04, 2018 at 02:35:59PM +0200, karl ramberg wrote:
> >
> > On Wed, Jul 4, 2018 at 11:10 AM K K Subbu <[hidden email]> wrote:
> >
> > > On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
> > > > 1. File-in the .cs as attached*.
> > > > 2. In a system browser, click on the class, then click on the [?] button
> > > > to view class comment.
> > > > 3. Notice the styled text in the comment.
> > > > 4. Click around the comment pane a bit.
> > > > 5. Eventually, see "Error: subscript is out of bounds: 71" appear over
> > > > and over until you interrupt.
> > > In step 4, it is sufficient to click once near the bottom of the pane
> > > when the cursor changes from I-bar to arrow and then wait. This will
> > > trigger the error, but the error window triggers itself recursively
> > > around 50 times before stopping and displaying the windows.
> > >
> > > I added an assert to catch it before recursion:
> > >
> > >     self assert: lastIndex < sourceString size.
> > >
> > > The assert window itself throws up another error, but that is a topic
> > > for another thread ;-).
> > >
> > > Regards .. Subbu
>
> >
> > Hi,
> > See class comment i NewParagraph for a hint of what happens.
> > A empty lineSpan 71 to: 70 is added to the end of the paragraph, when you
> > double click below the text.
> > When the character scanner looks for characters outside of the string at
> > index 71 it cause a recursion.
> >
> > Best,
> > Karl
> >
>
> Good tiip to look at the NewParagraph class comment, there is apparently
> some left over messiness in here somewhere.
>
> Another way to trigger the bug using the test case with FooClient is
> to position the cursor in the comment pane and use keyboard right cursor
> to move to the end of the comment. This causes the same bounds error but
> takes a different path through the code leading to the error.
>
> Looking through the stack in a debugger after triggering the error with
> the mouse, here are a few notes (but no conclusions):
>
> On mouseUp: we enter Editor>>selectWord then call Editor>>selectWordLeftDelimiters:rightDelimiters:
> which has this:
>
> "Select the whole text when clicking before first or after last character"
> (here > string size or: [here < 2]) ifTrue: [^self selectFrom: 1 to: string size].
>
> where string is the 70 character String derived from the Text.
>
> At this point we are trying to select from 1 to 70 (the whole string for
> the entire text) in TextEditor>>selectFrom:to:
>
> This calls Editor>>selectInvisiblyFrom:to: and here the stop index is
> set past the size of the string:
>
>   selectInvisiblyFrom: start to: stop
>      "Select the designated characters, inclusive.  Make no visual changes."
>
>      self markIndex: start pointIndex: stop + 1
>
> From this point we are trying to go from index 1 to index 71 over a string
> of size 70, and eventually end up with the out of bounds exception.
>
> A clue that this might be accumulation of kludges: Looking at senders of
> selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a number
> of methods that subtract 1 from the stop index when before calling the method
> that adds 1 back to the stop index. This certainly does not have a good smell.
>
> It is not clear to me why selectInvisiblyFrom:to: would be adding one to the
> stop index, but I see that the method stamp is jmv 5/27/2011, which suggests
> to me that we should take a look at Cuis to figure out how this is intended
> to function. Cuis does not show any cases of senders of selectInvisiblyFrom:to:
> that subtract 1 from the stop index, and the Cuis implementation of
> selectInvisiblyFrom:to: is that same as Squeak.
>
> Dave
>

One more note: This is an old bug. It is present in Squeak 4.1 but not in
Squeak 3.9 so whatever the cause, it has been with us for a while.

Dave

 

Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Chris Muller-3
In reply to this post by David T. Lewis
> It is not clear to me why selectInvisiblyFrom:to: would be adding one to the
> stop index, but I see that the method stamp is jmv 5/27/2011

Did you check the commit comment?   'browse origin'

Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

David T. Lewis
On Wed, Jul 04, 2018 at 11:50:19AM -0500, Chris Muller wrote:
> > It is not clear to me why selectInvisiblyFrom:to: would be adding one to the
> > stop index, but I see that the method stamp is jmv 5/27/2011
>
> Did you check the commit comment?   'browse origin'
>

The 'browse origin' search does not seem to find it (maybe I'm using it wrong?).

But the method originally entered Squeak here:

  Name: Morphic-ar.149
  Author: ar
  Time: 6 August 2009, 4:23:12 am
  UUID: fc14d160-97da-6142-8002-827d24037a57
  Ancestors: Morphic-jmv.148
 
  Integrate Cuis text editors. The new classes are Editor and TextEditor
  (in Morphic-Text Support). TextMorph now honors the preference
  #userNewEditors to determine whether to use the (old) TextMorphEditor
  or the (new) TextEditor (shameless plug: pragma preferences rock; check
  out TextMorph class>>useNewEditors).  There is still a ways to go before
  this will work but it gives us the starting point to knock down the
  remaining issues with the editors (mostly keyboard shortcut issues).


If you look at senders of selectInvisiblyFrom:to: in Squeak, there are
several cases where the sender subtracts 1 from the stop index before
sending. There are no such cases in Cuis.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Bob Arning-2
In reply to this post by David T. Lewis

perhaps this will help:

This version does not seem to exhibit the error and it limits stopIndex to the size of the string

!CharacterScanner methodsFor: 'scanning' stamp: 'cmm 6/12/2010 11:52'!
scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX stopConditions: stops kern: kernDelta

    | startEncoding selector |
    (sourceString isByteString) ifTrue: [^ self basicScanCharactersFrom: startIndex to: (stopIndex min: sourceString size) in: sourceString rightX: rightX stopConditions: stops kern: kernDelta.].

    (sourceString isWideString) ifTrue: [
        startIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ stops endOfRun].
        startEncoding :=  (sourceString at: startIndex) leadingChar.
        selector := EncodedCharSet scanSelectorAt: startEncoding.
        ^ self perform: selector withArguments: (Array with: startIndex with: stopIndex with: sourceString with: rightX with: stops with: kernDelta).
    ].
   
    ^ stops endOfRun
! !

This version fails and does not limit the stopIndex.

!CharacterScanner methodsFor: 'scanning' stamp: 'nice 10/22/2013 20:49'!
scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX
    ^sourceString scanCharactersFrom: startIndex to: stopIndex with: self rightX: rightX font: font! !


On 7/4/18 11:53 AM, David T. Lewis wrote:
On Wed, Jul 04, 2018 at 02:35:59PM +0200, karl ramberg wrote:
On Wed, Jul 4, 2018 at 11:10 AM K K Subbu [hidden email] wrote:

On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
1. File-in the .cs as attached*.
2. In a system browser, click on the class, then click on the [?] button
to view class comment.
3. Notice the styled text in the comment.
4. Click around the comment pane a bit.
5. Eventually, see "Error: subscript is out of bounds: 71" appear over
and over until you interrupt.
In step 4, it is sufficient to click once near the bottom of the pane
when the cursor changes from I-bar to arrow and then wait. This will
trigger the error, but the error window triggers itself recursively
around 50 times before stopping and displaying the windows.

I added an assert to catch it before recursion:

    self assert: lastIndex < sourceString size.

The assert window itself throws up another error, but that is a topic
for another thread ;-).

Regards .. Subbu

      
Hi,
See class comment i NewParagraph for a hint of what happens.
A empty lineSpan 71 to: 70 is added to the end of the paragraph, when you
double click below the text.
When the character scanner looks for characters outside of the string at
index 71 it cause a recursion.

Best,
Karl

Good tiip to look at the NewParagraph class comment, there is apparently
some left over messiness in here somewhere.

Another way to trigger the bug using the test case with FooClient is
to position the cursor in the comment pane and use keyboard right cursor
to move to the end of the comment. This causes the same bounds error but
takes a different path through the code leading to the error.

Looking through the stack in a debugger after triggering the error with
the mouse, here are a few notes (but no conclusions):

On mouseUp: we enter Editor>>selectWord then call Editor>>selectWordLeftDelimiters:rightDelimiters:
which has this:

	"Select the whole text when clicking before first or after last character"
	(here > string size or: [here < 2]) ifTrue: [^self selectFrom: 1 to: string size].

where string is the 70 character String derived from the Text.

At this point we are trying to select from 1 to 70 (the whole string for
the entire text) in TextEditor>>selectFrom:to:

This calls Editor>>selectInvisiblyFrom:to: and here the stop index is
set past the size of the string:

  selectInvisiblyFrom: start to: stop
     "Select the designated characters, inclusive.  Make no visual changes."

     self markIndex: start pointIndex: stop + 1

From this point we are trying to go from index 1 to index 71 over a string
of size 70, and eventually end up with the out of bounds exception.

A clue that this might be accumulation of kludges: Looking at senders of
selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a number
of methods that subtract 1 from the stop index when before calling the method
that adds 1 back to the stop index. This certainly does not have a good smell.

It is not clear to me why selectInvisiblyFrom:to: would be adding one to the
stop index, but I see that the method stamp is jmv 5/27/2011, which suggests
to me that we should take a look at Cuis to figure out how this is intended
to function. Cuis does not show any cases of senders of selectInvisiblyFrom:to:
that subtract 1 from the stop index, and the Cuis implementation of
selectInvisiblyFrom:to: is that same as Squeak.

Dave





Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

David T. Lewis
I tried reverting #scanCharactersFrom:to:in:rightX:stopConditions:kern:
to the earlier version (cmm 6/12/2010 11:52), but I still get failures
with cursor and mouse in the class comment text when browsing the FooClient
class. There must be something else going on here, and it is certainly
not obvious to me why it is happening only with the FooClient test
example.

Dave

On Wed, Jul 04, 2018 at 02:10:00PM -0400, Bob Arning wrote:

> perhaps this will help:
>
> This version does not seem to exhibit the error and it limits stopIndex
> to the size of the string
>
> !CharacterScanner methodsFor: 'scanning' stamp: 'cmm 6/12/2010 11:52'!
> scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX:
> rightX stopConditions: stops kern: kernDelta
>
> ?????? | startEncoding selector |
> ?????? (sourceString isByteString) ifTrue: [^ self
> basicScanCharactersFrom: startIndex *to: (stopIndex min: sourceString
> size)* in: sourceString rightX: rightX stopConditions: stops kern:
> kernDelta.].
>
> ?????? (sourceString isWideString) ifTrue: [
> ?????? ?????? startIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^
> stops endOfRun].
> ?????? ?????? startEncoding :=?? (sourceString at: startIndex) leadingChar.
> ?????? ?????? selector := EncodedCharSet scanSelectorAt: startEncoding.
> ?????? ?????? ^ self perform: selector withArguments: (Array with:
> startIndex with: stopIndex with: sourceString with: rightX with: stops
> with: kernDelta).
> ?????? ].
>
> ?????? ^ stops endOfRun
> ! !
>
> This version fails and does not limit the stopIndex.
>
> !CharacterScanner methodsFor: 'scanning' stamp: 'nice 10/22/2013 20:49'!
> scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX:
> rightX
> ?????? ^sourceString scanCharactersFrom: startIndex *to: stopIndex* with:
> self rightX: rightX font: font! !
>
>
> On 7/4/18 11:53 AM, David T. Lewis wrote:
> >On Wed, Jul 04, 2018 at 02:35:59PM +0200, karl ramberg wrote:
> >>On Wed, Jul 4, 2018 at 11:10 AM K K Subbu <[hidden email]> wrote:
> >>
> >>>On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
> >>>>1. File-in the .cs as attached*.
> >>>>2. In a system browser, click on the class, then click on the [?] button
> >>>>to view class comment.
> >>>>3. Notice the styled text in the comment.
> >>>>4. Click around the comment pane a bit.
> >>>>5. Eventually, see "Error: subscript is out of bounds: 71" appear over
> >>>>and over until you interrupt.
> >>>In step 4, it is sufficient to click once near the bottom of the pane
> >>>when the cursor changes from I-bar to arrow and then wait. This will
> >>>trigger the error, but the error window triggers itself recursively
> >>>around 50 times before stopping and displaying the windows.
> >>>
> >>>I added an assert to catch it before recursion:
> >>>
> >>>     self assert: lastIndex < sourceString size.
> >>>
> >>>The assert window itself throws up another error, but that is a topic
> >>>for another thread ;-).
> >>>
> >>>Regards .. Subbu
> >>Hi,
> >>See class comment i NewParagraph for a hint of what happens.
> >>A empty lineSpan 71 to: 70 is added to the end of the paragraph, when you
> >>double click below the text.
> >>When the character scanner looks for characters outside of the string at
> >>index 71 it cause a recursion.
> >>
> >>Best,
> >>Karl
> >>
> >Good tiip to look at the NewParagraph class comment, there is apparently
> >some left over messiness in here somewhere.
> >
> >Another way to trigger the bug using the test case with FooClient is
> >to position the cursor in the comment pane and use keyboard right cursor
> >to move to the end of the comment. This causes the same bounds error but
> >takes a different path through the code leading to the error.
> >
> >Looking through the stack in a debugger after triggering the error with
> >the mouse, here are a few notes (but no conclusions):
> >
> >On mouseUp: we enter Editor>>selectWord then call
> >Editor>>selectWordLeftDelimiters:rightDelimiters:
> >which has this:
> >
> > "Select the whole text when clicking before first or after last
> > character"
> > (here > string size or: [here < 2]) ifTrue: [^self selectFrom: 1 to:
> > string size].
> >
> >where string is the 70 character String derived from the Text.
> >
> >At this point we are trying to select from 1 to 70 (the whole string for
> >the entire text) in TextEditor>>selectFrom:to:
> >
> >This calls Editor>>selectInvisiblyFrom:to: and here the stop index is
> >set past the size of the string:
> >
> >   selectInvisiblyFrom: start to: stop
> >      "Select the designated characters, inclusive.  Make no visual
> >      changes."
> >
> >      self markIndex: start pointIndex: stop + 1
> >
> > From this point we are trying to go from index 1 to index 71 over a string
> >of size 70, and eventually end up with the out of bounds exception.
> >
> >A clue that this might be accumulation of kludges: Looking at senders of
> >selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a number
> >of methods that subtract 1 from the stop index when before calling the
> >method
> >that adds 1 back to the stop index. This certainly does not have a good
> >smell.
> >
> >It is not clear to me why selectInvisiblyFrom:to: would be adding one to
> >the
> >stop index, but I see that the method stamp is jmv 5/27/2011, which
> >suggests
> >to me that we should take a look at Cuis to figure out how this is intended
> >to function. Cuis does not show any cases of senders of
> >selectInvisiblyFrom:to:
> >that subtract 1 from the stop index, and the Cuis implementation of
> >selectInvisiblyFrom:to: is that same as Squeak.
> >
> >Dave
> >
> >
>

>


Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Bob Arning-2

It's only happening sometimes because of the styled text:

   runLength := text runLengthFor: line first.
    lineStop := characterIndex    "scanning for index"
        ifNil: [ line last ].            "scanning for point"
    runStopIndex := lastIndex + (runLength - 1) min: lineStop.

In unstyled text, runLength is zero and so runStopIndex is effectively decremented

In styled text, runStopIndex remains one past the end of the string

===================================

Reverting to the earlier version may not work (I was running that in squeak 4) due to other changes, but this does seem to work:

scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: rightX

    ^sourceString scanCharactersFrom: startIndex to: (stopIndex min: sourceString size) with: self rightX: rightX font: font


On 7/4/18 2:49 PM, David T. Lewis wrote:
I tried reverting #scanCharactersFrom:to:in:rightX:stopConditions:kern:
to the earlier version (cmm 6/12/2010 11:52), but I still get failures
with cursor and mouse in the class comment text when browsing the FooClient
class. There must be something else going on here, and it is certainly
not obvious to me why it is happening only with the FooClient test
example.

Dave

On Wed, Jul 04, 2018 at 02:10:00PM -0400, Bob Arning wrote:
perhaps this will help:

This version does not seem to exhibit the error and it limits stopIndex 
to the size of the string

!CharacterScanner methodsFor: 'scanning' stamp: 'cmm 6/12/2010 11:52'!
scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: 
rightX stopConditions: stops kern: kernDelta

?????? | startEncoding selector |
?????? (sourceString isByteString) ifTrue: [^ self 
basicScanCharactersFrom: startIndex *to: (stopIndex min: sourceString 
size)* in: sourceString rightX: rightX stopConditions: stops kern: 
kernDelta.].

?????? (sourceString isWideString) ifTrue: [
?????? ?????? startIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ 
stops endOfRun].
?????? ?????? startEncoding :=?? (sourceString at: startIndex) leadingChar.
?????? ?????? selector := EncodedCharSet scanSelectorAt: startEncoding.
?????? ?????? ^ self perform: selector withArguments: (Array with: 
startIndex with: stopIndex with: sourceString with: rightX with: stops 
with: kernDelta).
?????? ].

?????? ^ stops endOfRun
! !

This version fails and does not limit the stopIndex.

!CharacterScanner methodsFor: 'scanning' stamp: 'nice 10/22/2013 20:49'!
scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: 
rightX
?????? ^sourceString scanCharactersFrom: startIndex *to: stopIndex* with: 
self rightX: rightX font: font! !


On 7/4/18 11:53 AM, David T. Lewis wrote:
On Wed, Jul 04, 2018 at 02:35:59PM +0200, karl ramberg wrote:
On Wed, Jul 4, 2018 at 11:10 AM K K Subbu [hidden email] wrote:

On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
1. File-in the .cs as attached*.
2. In a system browser, click on the class, then click on the [?] button
to view class comment.
3. Notice the styled text in the comment.
4. Click around the comment pane a bit.
5. Eventually, see "Error: subscript is out of bounds: 71" appear over
and over until you interrupt.
In step 4, it is sufficient to click once near the bottom of the pane
when the cursor changes from I-bar to arrow and then wait. This will
trigger the error, but the error window triggers itself recursively
around 50 times before stopping and displaying the windows.

I added an assert to catch it before recursion:

    self assert: lastIndex < sourceString size.

The assert window itself throws up another error, but that is a topic
for another thread ;-).

Regards .. Subbu
Hi,
See class comment i NewParagraph for a hint of what happens.
A empty lineSpan 71 to: 70 is added to the end of the paragraph, when you
double click below the text.
When the character scanner looks for characters outside of the string at
index 71 it cause a recursion.

Best,
Karl

Good tiip to look at the NewParagraph class comment, there is apparently
some left over messiness in here somewhere.

Another way to trigger the bug using the test case with FooClient is
to position the cursor in the comment pane and use keyboard right cursor
to move to the end of the comment. This causes the same bounds error but
takes a different path through the code leading to the error.

Looking through the stack in a debugger after triggering the error with
the mouse, here are a few notes (but no conclusions):

On mouseUp: we enter Editor>>selectWord then call 
Editor>>selectWordLeftDelimiters:rightDelimiters:
which has this:

	"Select the whole text when clicking before first or after last 
	character"
	(here > string size or: [here < 2]) ifTrue: [^self selectFrom: 1 to: 
	string size].

where string is the 70 character String derived from the Text.

At this point we are trying to select from 1 to 70 (the whole string for
the entire text) in TextEditor>>selectFrom:to:

This calls Editor>>selectInvisiblyFrom:to: and here the stop index is
set past the size of the string:

  selectInvisiblyFrom: start to: stop
     "Select the designated characters, inclusive.  Make no visual 
     changes."

     self markIndex: start pointIndex: stop + 1

From this point we are trying to go from index 1 to index 71 over a string
of size 70, and eventually end up with the out of bounds exception.

A clue that this might be accumulation of kludges: Looking at senders of
selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a number
of methods that subtract 1 from the stop index when before calling the 
method
that adds 1 back to the stop index. This certainly does not have a good 
smell.

It is not clear to me why selectInvisiblyFrom:to: would be adding one to 
the
stop index, but I see that the method stamp is jmv 5/27/2011, which 
suggests
to me that we should take a look at Cuis to figure out how this is intended
to function. Cuis does not show any cases of senders of 
selectInvisiblyFrom:to:
that subtract 1 from the stop index, and the Cuis implementation of
selectInvisiblyFrom:to: is that same as Squeak.

Dave



      

      

      




Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Bob Arning-2
In reply to this post by David T. Lewis

Here is a side-by-side comparison with the styled version on the right and the same text unstyled on the left. Note the difference in runStopIndex


On 7/4/18 2:49 PM, David T. Lewis wrote:
I tried reverting #scanCharactersFrom:to:in:rightX:stopConditions:kern:
to the earlier version (cmm 6/12/2010 11:52), but I still get failures
with cursor and mouse in the class comment text when browsing the FooClient
class. There must be something else going on here, and it is certainly
not obvious to me why it is happening only with the FooClient test
example.

Dave

On Wed, Jul 04, 2018 at 02:10:00PM -0400, Bob Arning wrote:
perhaps this will help:

This version does not seem to exhibit the error and it limits stopIndex 
to the size of the string

!CharacterScanner methodsFor: 'scanning' stamp: 'cmm 6/12/2010 11:52'!
scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: 
rightX stopConditions: stops kern: kernDelta

?????? | startEncoding selector |
?????? (sourceString isByteString) ifTrue: [^ self 
basicScanCharactersFrom: startIndex *to: (stopIndex min: sourceString 
size)* in: sourceString rightX: rightX stopConditions: stops kern: 
kernDelta.].

?????? (sourceString isWideString) ifTrue: [
?????? ?????? startIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^ 
stops endOfRun].
?????? ?????? startEncoding :=?? (sourceString at: startIndex) leadingChar.
?????? ?????? selector := EncodedCharSet scanSelectorAt: startEncoding.
?????? ?????? ^ self perform: selector withArguments: (Array with: 
startIndex with: stopIndex with: sourceString with: rightX with: stops 
with: kernDelta).
?????? ].

?????? ^ stops endOfRun
! !

This version fails and does not limit the stopIndex.

!CharacterScanner methodsFor: 'scanning' stamp: 'nice 10/22/2013 20:49'!
scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX: 
rightX
?????? ^sourceString scanCharactersFrom: startIndex *to: stopIndex* with: 
self rightX: rightX font: font! !


On 7/4/18 11:53 AM, David T. Lewis wrote:
On Wed, Jul 04, 2018 at 02:35:59PM +0200, karl ramberg wrote:
On Wed, Jul 4, 2018 at 11:10 AM K K Subbu [hidden email] wrote:

On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
1. File-in the .cs as attached*.
2. In a system browser, click on the class, then click on the [?] button
to view class comment.
3. Notice the styled text in the comment.
4. Click around the comment pane a bit.
5. Eventually, see "Error: subscript is out of bounds: 71" appear over
and over until you interrupt.
In step 4, it is sufficient to click once near the bottom of the pane
when the cursor changes from I-bar to arrow and then wait. This will
trigger the error, but the error window triggers itself recursively
around 50 times before stopping and displaying the windows.

I added an assert to catch it before recursion:

    self assert: lastIndex < sourceString size.

The assert window itself throws up another error, but that is a topic
for another thread ;-).

Regards .. Subbu
Hi,
See class comment i NewParagraph for a hint of what happens.
A empty lineSpan 71 to: 70 is added to the end of the paragraph, when you
double click below the text.
When the character scanner looks for characters outside of the string at
index 71 it cause a recursion.

Best,
Karl

Good tiip to look at the NewParagraph class comment, there is apparently
some left over messiness in here somewhere.

Another way to trigger the bug using the test case with FooClient is
to position the cursor in the comment pane and use keyboard right cursor
to move to the end of the comment. This causes the same bounds error but
takes a different path through the code leading to the error.

Looking through the stack in a debugger after triggering the error with
the mouse, here are a few notes (but no conclusions):

On mouseUp: we enter Editor>>selectWord then call 
Editor>>selectWordLeftDelimiters:rightDelimiters:
which has this:

	"Select the whole text when clicking before first or after last 
	character"
	(here > string size or: [here < 2]) ifTrue: [^self selectFrom: 1 to: 
	string size].

where string is the 70 character String derived from the Text.

At this point we are trying to select from 1 to 70 (the whole string for
the entire text) in TextEditor>>selectFrom:to:

This calls Editor>>selectInvisiblyFrom:to: and here the stop index is
set past the size of the string:

  selectInvisiblyFrom: start to: stop
     "Select the designated characters, inclusive.  Make no visual 
     changes."

     self markIndex: start pointIndex: stop + 1

From this point we are trying to go from index 1 to index 71 over a string
of size 70, and eventually end up with the out of bounds exception.

A clue that this might be accumulation of kludges: Looking at senders of
selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a number
of methods that subtract 1 from the stop index when before calling the 
method
that adds 1 back to the stop index. This certainly does not have a good 
smell.

It is not clear to me why selectInvisiblyFrom:to: would be adding one to 
the
stop index, but I see that the method stamp is jmv 5/27/2011, which 
suggests
to me that we should take a look at Cuis to figure out how this is intended
to function. Cuis does not show any cases of senders of 
selectInvisiblyFrom:to:
that subtract 1 from the stop index, and the Cuis implementation of
selectInvisiblyFrom:to: is that same as Squeak.

Dave



      

      

      




Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

David T. Lewis
On Wed, Jul 04, 2018 at 03:46:16PM -0400, Bob Arning wrote:
> Here is a side-by-side comparison with the styled version on the right
> and the same text unstyled on the left. Note the difference in runStopIndex
>

I see it now. Thanks!

Dave


>
> On 7/4/18 2:49 PM, David T. Lewis wrote:
> >I tried reverting #scanCharactersFrom:to:in:rightX:stopConditions:kern:
> >to the earlier version (cmm 6/12/2010 11:52), but I still get failures
> >with cursor and mouse in the class comment text when browsing the FooClient
> >class. There must be something else going on here, and it is certainly
> >not obvious to me why it is happening only with the FooClient test
> >example.
> >
> >Dave
> >
> >On Wed, Jul 04, 2018 at 02:10:00PM -0400, Bob Arning wrote:
> >>perhaps this will help:
> >>
> >>This version does not seem to exhibit the error and it limits stopIndex
> >>to the size of the string
> >>
> >>!CharacterScanner methodsFor: 'scanning' stamp: 'cmm 6/12/2010 11:52'!
> >>scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX:
> >>rightX stopConditions: stops kern: kernDelta
> >>
> >>?????? | startEncoding selector |
> >>?????? (sourceString isByteString) ifTrue: [^ self
> >>basicScanCharactersFrom: startIndex *to: (stopIndex min: sourceString
> >>size)* in: sourceString rightX: rightX stopConditions: stops kern:
> >>kernDelta.].
> >>
> >>?????? (sourceString isWideString) ifTrue: [
> >>?????? ?????? startIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^
> >>stops endOfRun].
> >>?????? ?????? startEncoding :=?? (sourceString at: startIndex)
> >>leadingChar.
> >>?????? ?????? selector := EncodedCharSet scanSelectorAt: startEncoding.
> >>?????? ?????? ^ self perform: selector withArguments: (Array with:
> >>startIndex with: stopIndex with: sourceString with: rightX with: stops
> >>with: kernDelta).
> >>?????? ].
> >>
> >>?????? ^ stops endOfRun
> >>! !
> >>
> >>This version fails and does not limit the stopIndex.
> >>
> >>!CharacterScanner methodsFor: 'scanning' stamp: 'nice 10/22/2013 20:49'!
> >>scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX:
> >>rightX
> >>?????? ^sourceString scanCharactersFrom: startIndex *to: stopIndex* with:
> >>self rightX: rightX font: font! !
> >>
> >>
> >>On 7/4/18 11:53 AM, David T. Lewis wrote:
> >>>On Wed, Jul 04, 2018 at 02:35:59PM +0200, karl ramberg wrote:
> >>>>On Wed, Jul 4, 2018 at 11:10 AM K K Subbu <[hidden email]> wrote:
> >>>>
> >>>>>On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
> >>>>>>1. File-in the .cs as attached*.
> >>>>>>2. In a system browser, click on the class, then click on the [?]
> >>>>>>button
> >>>>>>to view class comment.
> >>>>>>3. Notice the styled text in the comment.
> >>>>>>4. Click around the comment pane a bit.
> >>>>>>5. Eventually, see "Error: subscript is out of bounds: 71" appear over
> >>>>>>and over until you interrupt.
> >>>>>In step 4, it is sufficient to click once near the bottom of the pane
> >>>>>when the cursor changes from I-bar to arrow and then wait. This will
> >>>>>trigger the error, but the error window triggers itself recursively
> >>>>>around 50 times before stopping and displaying the windows.
> >>>>>
> >>>>>I added an assert to catch it before recursion:
> >>>>>
> >>>>>     self assert: lastIndex < sourceString size.
> >>>>>
> >>>>>The assert window itself throws up another error, but that is a topic
> >>>>>for another thread ;-).
> >>>>>
> >>>>>Regards .. Subbu
> >>>>Hi,
> >>>>See class comment i NewParagraph for a hint of what happens.
> >>>>A empty lineSpan 71 to: 70 is added to the end of the paragraph, when
> >>>>you
> >>>>double click below the text.
> >>>>When the character scanner looks for characters outside of the string at
> >>>>index 71 it cause a recursion.
> >>>>
> >>>>Best,
> >>>>Karl
> >>>>
> >>>Good tiip to look at the NewParagraph class comment, there is apparently
> >>>some left over messiness in here somewhere.
> >>>
> >>>Another way to trigger the bug using the test case with FooClient is
> >>>to position the cursor in the comment pane and use keyboard right cursor
> >>>to move to the end of the comment. This causes the same bounds error but
> >>>takes a different path through the code leading to the error.
> >>>
> >>>Looking through the stack in a debugger after triggering the error with
> >>>the mouse, here are a few notes (but no conclusions):
> >>>
> >>>On mouseUp: we enter Editor>>selectWord then call
> >>>Editor>>selectWordLeftDelimiters:rightDelimiters:
> >>>which has this:
> >>>
> >>> "Select the whole text when clicking before first or after last
> >>> character"
> >>> (here > string size or: [here < 2]) ifTrue: [^self selectFrom: 1 to:
> >>> string size].
> >>>
> >>>where string is the 70 character String derived from the Text.
> >>>
> >>>At this point we are trying to select from 1 to 70 (the whole string for
> >>>the entire text) in TextEditor>>selectFrom:to:
> >>>
> >>>This calls Editor>>selectInvisiblyFrom:to: and here the stop index is
> >>>set past the size of the string:
> >>>
> >>>   selectInvisiblyFrom: start to: stop
> >>>      "Select the designated characters, inclusive.  Make no visual
> >>>      changes."
> >>>
> >>>      self markIndex: start pointIndex: stop + 1
> >>>
> >>> From this point we are trying to go from index 1 to index 71 over a
> >>> string
> >>>of size 70, and eventually end up with the out of bounds exception.
> >>>
> >>>A clue that this might be accumulation of kludges: Looking at senders of
> >>>selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a
> >>>number
> >>>of methods that subtract 1 from the stop index when before calling the
> >>>method
> >>>that adds 1 back to the stop index. This certainly does not have a good
> >>>smell.
> >>>
> >>>It is not clear to me why selectInvisiblyFrom:to: would be adding one to
> >>>the
> >>>stop index, but I see that the method stamp is jmv 5/27/2011, which
> >>>suggests
> >>>to me that we should take a look at Cuis to figure out how this is
> >>>intended
> >>>to function. Cuis does not show any cases of senders of
> >>>selectInvisiblyFrom:to:
> >>>that subtract 1 from the stop index, and the Cuis implementation of
> >>>selectInvisiblyFrom:to: is that same as Squeak.
> >>>
> >>>Dave
> >>>
> >>>
> >
>

>


Reply | Threaded
Open this post in threaded view
|

Re: [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

Bob Arning-2

A little more...

This problem may ultimately be due to something broken in the text being displayed. If I look at the funky class comment, it has these runs

a RunArray runs: #(1 35 18 20 3) values: {#() . {a TextFontChange font: 1} . #() . {a TextEmphasis code: 1} . #()}

The total length of the run sizes is 77, yet the string is only 70 bytes long.

If I copy that text out and paste into a workspace, the runs now look like:

a RunArray runs: #(1 35 18 16) values: {#() . {a TextFontChange font: 1} . #() . {a TextEmphasis code: 1}}

and the size of the runs matches the size of the string at 70. I wonder if other occurrences of this problem might have a similar cause.


On 7/4/18 4:20 PM, David T. Lewis wrote:
On Wed, Jul 04, 2018 at 03:46:16PM -0400, Bob Arning wrote:
Here is a side-by-side comparison with the styled version on the right 
and the same text unstyled on the left. Note the difference in runStopIndex

I see it now. Thanks!

Dave


On 7/4/18 2:49 PM, David T. Lewis wrote:
I tried reverting #scanCharactersFrom:to:in:rightX:stopConditions:kern:
to the earlier version (cmm 6/12/2010 11:52), but I still get failures
with cursor and mouse in the class comment text when browsing the FooClient
class. There must be something else going on here, and it is certainly
not obvious to me why it is happening only with the FooClient test
example.

Dave

On Wed, Jul 04, 2018 at 02:10:00PM -0400, Bob Arning wrote:
perhaps this will help:

This version does not seem to exhibit the error and it limits stopIndex
to the size of the string

!CharacterScanner methodsFor: 'scanning' stamp: 'cmm 6/12/2010 11:52'!
scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX:
rightX stopConditions: stops kern: kernDelta

?????? | startEncoding selector |
?????? (sourceString isByteString) ifTrue: [^ self
basicScanCharactersFrom: startIndex *to: (stopIndex min: sourceString
size)* in: sourceString rightX: rightX stopConditions: stops kern:
kernDelta.].

?????? (sourceString isWideString) ifTrue: [
?????? ?????? startIndex > stopIndex ifTrue: [lastIndex := stopIndex. ^
stops endOfRun].
?????? ?????? startEncoding :=?? (sourceString at: startIndex) 
leadingChar.
?????? ?????? selector := EncodedCharSet scanSelectorAt: startEncoding.
?????? ?????? ^ self perform: selector withArguments: (Array with:
startIndex with: stopIndex with: sourceString with: rightX with: stops
with: kernDelta).
?????? ].

?????? ^ stops endOfRun
! !

This version fails and does not limit the stopIndex.

!CharacterScanner methodsFor: 'scanning' stamp: 'nice 10/22/2013 20:49'!
scanCharactersFrom: startIndex to: stopIndex in: sourceString rightX:
rightX
?????? ^sourceString scanCharactersFrom: startIndex *to: stopIndex* with:
self rightX: rightX font: font! !


On 7/4/18 11:53 AM, David T. Lewis wrote:
On Wed, Jul 04, 2018 at 02:35:59PM +0200, karl ramberg wrote:
On Wed, Jul 4, 2018 at 11:10 AM K K Subbu [hidden email] wrote:

On Tuesday 03 July 2018 04:40 AM, Tim Johnson wrote:
1. File-in the .cs as attached*.
2. In a system browser, click on the class, then click on the [?] 
button
to view class comment.
3. Notice the styled text in the comment.
4. Click around the comment pane a bit.
5. Eventually, see "Error: subscript is out of bounds: 71" appear over
and over until you interrupt.
In step 4, it is sufficient to click once near the bottom of the pane
when the cursor changes from I-bar to arrow and then wait. This will
trigger the error, but the error window triggers itself recursively
around 50 times before stopping and displaying the windows.

I added an assert to catch it before recursion:

    self assert: lastIndex < sourceString size.

The assert window itself throws up another error, but that is a topic
for another thread ;-).

Regards .. Subbu
Hi,
See class comment i NewParagraph for a hint of what happens.
A empty lineSpan 71 to: 70 is added to the end of the paragraph, when 
you
double click below the text.
When the character scanner looks for characters outside of the string at
index 71 it cause a recursion.

Best,
Karl

Good tiip to look at the NewParagraph class comment, there is apparently
some left over messiness in here somewhere.

Another way to trigger the bug using the test case with FooClient is
to position the cursor in the comment pane and use keyboard right cursor
to move to the end of the comment. This causes the same bounds error but
takes a different path through the code leading to the error.

Looking through the stack in a debugger after triggering the error with
the mouse, here are a few notes (but no conclusions):

On mouseUp: we enter Editor>>selectWord then call
Editor>>selectWordLeftDelimiters:rightDelimiters:
which has this:

	"Select the whole text when clicking before first or after last
	character"
	(here > string size or: [here < 2]) ifTrue: [^self selectFrom: 1 to:
	string size].

where string is the 70 character String derived from the Text.

At this point we are trying to select from 1 to 70 (the whole string for
the entire text) in TextEditor>>selectFrom:to:

This calls Editor>>selectInvisiblyFrom:to: and here the stop index is
set past the size of the string:

  selectInvisiblyFrom: start to: stop
     "Select the designated characters, inclusive.  Make no visual
     changes."

     self markIndex: start pointIndex: stop + 1

From this point we are trying to go from index 1 to index 71 over a 
string
of size 70, and eventually end up with the out of bounds exception.

A clue that this might be accumulation of kludges: Looking at senders of
selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a 
number
of methods that subtract 1 from the stop index when before calling the
method
that adds 1 back to the stop index. This certainly does not have a good
smell.

It is not clear to me why selectInvisiblyFrom:to: would be adding one to
the
stop index, but I see that the method stamp is jmv 5/27/2011, which
suggests
to me that we should take a look at Cuis to figure out how this is 
intended
to function. Cuis does not show any cases of senders of
selectInvisiblyFrom:to:
that subtract 1 from the stop index, and the Cuis implementation of
selectInvisiblyFrom:to: is that same as Squeak.

Dave



        

      

      

      




12