[squeak-dev] The Trunk: Collections-dtl.560.mcz

David T. Lewis lewis at mail.msen.com
Sun Jan 19 00:29:42 UTC 2014


On Fri, Jan 17, 2014 at 11:51:00AM -0500, David T. Lewis wrote:
> >> How was the source for this version of #workingWithSqueak created? I am
> >> worried that I might have broken something in the writeScanOn: methods
> >> for TextAttributes that might have led to generating corrupt source
> >> code for the workingWithSqueak method ... I hope not :-(
> >
> > It was created the normal way -- by simply opening up that workspace,
> > editing it, and then saving it (Command+s).
> >
> > Doing that updates the method source.
> >
> > See the acceptBlock in TheWorldMainDockingBar>>#showWelcomeText:label:in:.
> >
> 
> That means that I must have introduced some new bug. I will look for it
> and provide a fix this weekend.

Oh my goodness. This appears to be a remarkable confluence of of bugs.

The welcome text right now just happens to be a Text with a RunArray that
serializes to a string of exactly 101 characters, including a trailing comma
that needs to be trimmed. The RunArray>>writeScanOn: method backs the stream
up one character to trim off that extra comma, leaving the stream at position
100. It just so happens that the stream was initialized to size 100, so when
String>>new:streamContents: checks to see if the stream position matches the
original size, it sees that the position is 100 so yes they match and it must
be OK to simply return the #originalContents of the stream instead of going
to all the extra work of figuring out its current #contents. Unfortunately,
the stream has actually been advanced to position 101 before being backed
up to position 100, so its collection has been resized to 200 elements. So
we grab the 200 elements of the stream collection, assuming that these are
still the original 100 elements of the original stream collection. That
gives us a string with an extra comma and 99 null characters at the end
where we did not expect anything.

If I load our current #workingWithSqueak into an older Squeak image, the
above problem is still triggered, and the source code for #workingWithSqueak
gets corrupted. But it gets corrupted differently than in the latest Squeak,
presumably due to the changes that I recently made to TextAttributes. And
in the older Squeak, this mess does not result in an error when opening the
workingWithSqueak window, probably related to the more permissive parsing
in the original RunArray class>>scanFrom: parsing.

This is making my head hurt. I am going to think about it tomorrow.

"I can't think about that right now. If I do, I'll go crazy. I'll think about that tomorrow."
- Margaret Mitchell, Gone with the Wind 

Dave



More information about the Squeak-dev mailing list