Bug in FileStream

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

Bug in FileStream

Bill Dargel
Found a bug in FileStream as it's used for the change log.

I suspect that it's been there for a long time, but there's nothing like
trying new things to uncover old problems. Did I say thank you for
getting X6 released? Thank you for getting X6 released! :-)

Okay. Ran into an infinite loop trying to open a MethodHistoryBrowser.
It probably hasn't been seen before because it looks like the change log
has to still be within the first page of file, and how long does a
change log stay that small?

Take a fresh X6 image. My .chg file was 360 bytes after having done a
save. After starting up is logged, it's 445 bytes. Your exact numbers
may vary. Open SUnit Browser. Pick a test case. Do Test|Step. Open the
debugger. In the stack frame context menu select Browse|Change History
in Image. It'll go into an infinite loop. Hit Ctrl-Break. The debugger
will show that it's looping endlessly in
ChunkFileMethodScanner>>positionsOf:in:firstOnly:. Now investigate
without doing any evaluations in the debugger, since they'd get logged,
and therefore change everything. :-(

The crux of the problem is that #nextAvailable:500000, which does an
#upToEnd doesn't get there -- #atEnd answers false. This is because in
the FileStream, logicalFileSize=445 while readLimit=447. Not sure how it
gets that way. Seems like they should be kept in sync. There seems to be
a CR-LF between the logicalFileSize and readLimit positions.

Ah, a simpler demonstration of the problem:

        (FileStream write: 'test.tmp')
                next: 3 put: $A;
                reset;
                upToEnd;
                atEnd. " --> false "

        (FileStream write: 'test.tmp')
                next: 9999 put: $A;
                reset;
                upToEnd;
                atEnd. " --> true "

Using "(ReadWriteStream on: String new)" both will answer true.

Potential fix is to add "self lastPosition." to the beginning of
FileStream>>position:. Or alternatively replace "readLimit < position
ifTrue: [readLimit := position]." there with "self size" for its side
effects (like #writePage does). Though I'm not sure whether this covers
all the places where logicalFileSize needs to be updated.

--
Bill Dargel            [hidden email]
Shoshana Technologies
100 West Joy Road, Ann Arbor, MI 48105  USA


Reply | Threaded
Open this post in threaded view
|

Re: Bug in FileStream

Andy Bower-3
Bill,

> Found a bug in FileStream as it's used for the change log.

Thanks, this has been recorded as issue #2008. One for the first patch
release, I think.

Best regards,

--
Andy Bower
Dolphin Support
www.object-arts.com


Reply | Threaded
Open this post in threaded view
|

Re: Bug in FileStream

Ian Bartholomew-21
Andy,

>> Found a bug in FileStream as it's used for the change log.
>
> Thanks, this has been recorded as issue #2008. One for the first patch
> release, I think.

It should already be in there Andy, #1724, although I don't think I got
it down to the nice neat examples that Bill posted.


--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.